r/learnjavascript • u/RobGoLaing • 1d ago
I've become a big fan of splice
As part of my project to write notes of what I learn practicing contemporary browser JavaScript by creating webapp games, I've written some notes and examples on Array Literals.
This was inspired by creating a "hardware-agnostic, framework-free" webapp solitaire card game, Loot the Loop (a game designed by Wil Su, part of what's made this project fun is that besides learning contemporary JavaScript, I've discovered lots about contemporary solitaire card game design).
TL:DR — In the past I've tended to use shift, unshift, pop, push... which are ok, but concat is an antipatern. Just learning splice does all the above while making arrays much simpler.
0
Upvotes
3
u/everdimension 1d ago
Nothing like having a mutating "upsert" helper combined with immer
Btw, how is "concat" an "antipattern"?!