Shortening an Array

we can shorten an array using the length method by passing a number that denotes the new size of your array.

let array = ["A", "B", "C", "D", "E", "F"]
array.length=2
console.log(array) // ["A", "B"]

Leave a comment

Your email address will not be published. Required fields are marked *