DEV Community

loading...

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

Collapse
samanthaming profile image
Samantha Ming Author

Yes! Good one, let me add it to my notes 💪 Thanks for sharing 😀

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 Author

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