Truncate an Array by setting its length
Today I Learned that in JavaScript an Array can be truncated by simply setting its length 🤯
Here is an example:
const myArray = [1, 2, 4, 8, 16, 32, 64, 128]
myArray.length = 4
console.log(myArray)
// [1,2,4,8]