Declaring an array
var tmp=[];//简写模式var tmp= new Array();//直接new一个var tmp=array(); //直接new一个
In the new array, you can pass in a parameter that represents the initialization length of the array.
var tmp = new array();数组的元素可以是任意的var tmp=[3,true,8.5,'ssgao',[a,b],{'name':'lin'}];
Unshift inserting an element before the first element of the array
//使用unshift在数组第一个元素前插入元素,并返回数组长度var tmp =['a','b'];var len= tmp.unshift('c');// len=3, tmp=[c,a,b]var len= tmp.unshift('d,e');//tmp=[d,e,a,b]
Shift pops the value of the first element of the array, returning the value of the element being popped
var tmp=[a,b,c];var val=tmp.shift();//val=a,tmp=[b,c];
Push adds an element at the end of the array, returning the length of the array after the element is added
var tmp=['a','b','c'];var len=tmp.push('d')//len=4 tmp=['a','b','c','d'];
The pop function deletes the element at the end of the array
var tmp=['a','b','c'];var val=tmp.pop(); //val=c;tmp=['a','b']
JavaScript array functions