How to use mini program push

Release: 2020-04-03 09:01:45
Original
8842 people have browsed it

How to use mini program push

The push() method in the applet can add one or more elements to the end of the array and return the new length. When push encounters an array parameter, it treats the entire array parameter as one element.

Syntax

arrayObject.push(newelement1,newelement2,....,newelementX)
Copy after login

The functions of push and concat are very similar:

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]);
}
Copy after login

The printing result is as follows:

index.js [sm]: 180 0-----1

index.js [sm]:180 1-----2

index.js [sm]:180 2-----3 ,4

index.js [sm]:180 3-----5

index.js [sm]:180 4-----6

index.js [sm]:180 5-----7

index.js [sm]:180 6-----8

index.js [sm]:180 7-----9

index.js [sm]:180 8-----10

index.js [sm]:180 9-----11

Recommendation: " Mini Program Development Tutorial"

The above is the detailed content of How to use mini program push. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!