Thursday, August 1, 2013

JavaScript arrayunshift

<html>
<body>

<script type="text/javascript">

var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.write(fruits.unshift("Kiwi") + "<br />");
document.write(fruits.unshift("Lemon","Pineapple") + "<br />");
document.write(fruits);

</script>

<p><b>Note:</b> The unshift() method does not work properly in Internet Explorer, it only returns undefined!</p>

</body>
</html>
Result

No comments: