DEV Community

Discussion on: 5 Way to Append Item to Array in JavaScript

Collapse
 
devhammed profile image
Hammed Oyedele

You can also use it to shrink array

const array = [1, 2]

array.length = 1

console.log(array) // [1]
Thread Thread
 
samanthaming profile image
Samantha Ming

WOOO! never thought of that! Adding to my notes!!! thanks for sharing 😁