javascript数组的长度不是只读属性

var arr = ['a', 'b', 'c', 'd', 'e', 'f']; 
// length:6, 0:a, 1:b, 2:c, 3:d, 4:e, 5:f
arr.length = 5;
// length:5, 0:a, 1:b, 2:c, 3:d, 4:e

看看这篇文章吧 

http://www.sitepoint.com/quick-tip-create-manipulate-arrays-in-javascript/

猜你喜欢

转载自my.oschina.net/u/1240534/blog/625359
今日推荐