
小程序中push()方法可向数组的末尾添加一个或多个元素,并返回新的长度。push遇到数组参数时,把整个数组参数作为一个元素。
语法
arrayObject.push(newelement1,newelement2,....,newelementX)
push和concat二者功能很相像:
小程序管理平台系统源码是一套面向小程序服务商的一站式管理程序,基于 uniapp + ThinkPHP(PHP)开发,支持微信小程序、微信公众号与 H5 端。系统主打"全开源、独立部署、无限开 SAAS 账号",适合需要集中管理多个小程序、为客户代开通与授权的小程序服务商使用。
var arr = [];
arr.push(1);
arr.push(2);
arr.push([3, 4])
arr.push(5, 6);
arr = arr.concat(7);
arr = arr.concat([8, 9]);
arr = arr.concat(10, 11);
for(var i in arr){
console.log(i+"-----"+arr[i]);
}
打印结果如下:
index.js [sm]:180 0-----1index.js [sm]:180 1-----2index.js [sm]:180 2-----3,4index.js [sm]:180 3-----5index.js [sm]:180 4-----6index.js [sm]:180 5-----7index.js [sm]:180 6-----8index.js [sm]:180 7-----9index.js [sm]:180 8-----10index.js [sm]:180 9-----11
推荐:《小程序开发教程》










