>>> var arr = ['john', 'tom', 'sam', 'chichi'];
>>> arr.push();//return arr.length;
4
>>> arr
[ "john" , "tom" , "sam" , "chichi" ]
>>> arr.pop();//remove the last element from the array return the last element of the array;
"chichi"
>>> arr
[ "john" , "tom" , "sam" ]
>>> arr.push('hanmeimei');
4
>>> arr
[ "john" , "tom" , "sam" , "hanmeimei" ]
|
0
| "john" |
|
1
| "tom" |
|
2
| "sam" |
|
3
| "hanmeimei" |
>>> arr.shift()
"john"
>>> arr
[ "tom" , "sam" , "hanmeimei" ]
>>> arr.unshift()
3
>>> arr
[ "tom" , "sam" , "hanmeimei" ]
>>> arr.unshift('lingtao')
4
>>> arr
[ "lingtao" , "tom" , "sam" , "hanmeimei" ]
不想说啦!自己看吧,经firebug调试过