DEV Community

Discussion on: Immutable Arrays and Objects in JavaScript, the Native Way

Collapse
 
costinmanda profile image
Costin Manda

Shift can also be achieved with the spread operator:

const arr=[1,2,3];
const [x,...y]=arr;
// now x = 1 and y = [2,3]
Enter fullscreen mode Exit fullscreen mode