Resize or Empty an Array Using array.length

重置或者清空数据的简单方法

resize-array.js

let array = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];

console.log(array.length); // returns the length as 10

array.length = 4;

console.log(array.length); // returns the length as 4
console.log(array); // returns ['a', 'b', 'c', 'd']

版权声明:著作权归作者所有。

thumb_up 1 | star_outline 0 | textsms 0