jQuery的push

赵兴朝
2023-12-01

1.简述

push数组尾部加元素  返回个数

unshift数组头部加元素    返回个数

2.代码

<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

 

 类似资料: