DEV Community

Discussion on: What's your favorite addition to ES2015+

Collapse
 
jrios profile image
Jake Rios

Using the spread operator to append/prepend elements to an array. It also returns the array rather than the length of the array, which I've never found that useful.


let numbers = [1, 2, 3]

numbers = [...numbers, 4]

// [1, 2, 3, 4]

Collapse
 
itsjzt profile image
Saurabh Sharma

I wish there could be such an easy way to remove elements from array.

Collapse
 
laurieontech profile image
Laurie

Spread operator is wonderful. What's crazy to me is how many different ways it can be used. Like arrays vs. objects.

Collapse
 
kenbellows profile image
Ken Bellows

oh man, Object spread is the best thing... maybe I should change my answer 🤔