DEV Community

Discussion on: How to shift array position in vanilla JavaScript

 
link2twenty profile image
Andrew Bone • Edited

Good point, you'd have to do something like

const lastToFirst = _ => {const $ = _.slice(); return [$.pop(), ...$]};

which is even more convoluted.

Thread Thread
 
lexlohr profile image
Alex Lohr

How about const lastToFirst = _ => ($ => [$.pop(), ...$])(_.slice()) as even more convoluted example?

Thread Thread
 
link2twenty profile image
Andrew Bone

Yikes...

I kinda love it.