push()方法返回的是数组新的长度

实例

在本例中,我们将创建一个数组,并通过添加一个元素来改变其长度:

<script type="text/javascript">

var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"

document.write(arr + "<br />")
document.write(arr.push("James") + "<br />")
document.write(arr)

</script>

输出:

George,John,Thomas
4
George,John,Thomas,James
原文地址:https://www.cnblogs.com/luziluck/p/9244337.html