JavaScript push()

Example

Add new elements to the end of an array, and return the new length:

<script type="text/javascript">

var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.write(fruits.push("Kiwi") + "<br />");//返回数组长度,5
document.write(fruits.push("Lemon","Pineapple") + "<br />");//返回数组最末位的值:7
document.write(fruits);

</script>

The output of the code above will be:

5
7
Banana,Orange,Apple,Mango,Kiwi,Lemon,Pineapple

你可能感兴趣的:(JavaScript,apple)