JavaScript array.push()方法将给定元素追加到数组中,并返回新数组的长度。
array.push(element1, ..., elementN);
Element1...elementN - 要添加到数组末尾的元素。
返回新数组的长度。
链接:https://www.learnfk.comhttps://www.learnfk.com/javascript/array-push.html
来源:LearnFk无涯教程网
<html> <head> <title>JavaScript Array push Method</title> </head> <body> <script type="text/javascript"> var numbers=new Array(1, 4, 9); var length=numbers.push(10); document.write("new numbers is : " + numbers ); length=numbers.push(20); document.write("<br />new numbers is : " + numbers ); </script> </body> </html>
运行上面代码输出
new numbers is : 1,4,9,10 new numbers is : 1,4,9,10,20
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Tony Bai · Go语言第一课 -〔Tony Bai〕