DEV Community

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

Collapse
 
samanthaming profile image
Samantha Ming

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

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