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/
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/
转载于:https://my.oschina.net/u/1240534/blog/625359