Mini Program Learning Record [Array operation related (continuous update)] (1)

 

push() method in js

The push() method is to add one or more elements at the end of the array separated by commas (,) and return the new length;

E.g:

var  char = []
 char .push("I am a newly added element") 
char.push("first","second")

The pop() method in js

The pop() method deletes the last element in the array, decrements the length of the array by 1, and returns the value of the element it deletes. If the array is already empty, it does not change the array and returns an undefined value;

var  char = ['one','two','three'] 
char.pop()

//The array information after operation is char = ['one','two']

 The join() method in js

The join() method is to add a specified string between elements when outputting an array, and divide the elements of the array

var char = ['one','two','three']
document.write(char.join("-"));
//输出为 one-two-three

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324853820&siteId=291194637