Truncate JavaScript array using length
Here are few examples to truncate JavaScript array using length property
var chars = ["a", "w", "r", "t", "y", "y"];
console.log(chars); // ["a", "w", "r", "t", "y", "y"];
chars.length = 2;
console.log(chars); // ["a", "w"];
chars.length = 0;
console.log(chars); // [];
Comments
Post a Comment