JavaScript Array Immutability Cheatsheet

preview_player
Показать описание
I've got a new cheetsheet you'll like that covers how to covert all the old destructive methods to immutable methods that are more compatible with React.

#shorts
Рекомендации по теме
Комментарии
Автор

I love how "destructively" sounds more aggressive, but in reality the "immutable" way is the one destroying and re-allocating constantly.

LuismaLorca
Автор

Idk why the React team chose to have this requirement. Flutter for example does not force you to create a new state to signal change, rather that you need to call setState. I guess someone in the team really liked functional programming.

parlor
Автор

We can also do with slice to make it non destructive

iammascot
Автор

I didn't know about those "to" methods. Nice!

ShaharHarshuv
Автор

Very helpful content on react array methods

BlackFlux
Автор

If you listen closely you can hear GC's crying

stangeorge
Автор

I didn't know about the new Array methods like with( ) and toSort( ). That's really cool.

When were those introduced? Which ES version?

bigk
Автор

Does it work fine if I use the function version of setState with the destructive methods?

setTodos((todoArray) => todoArray.shift())

dragxdd
Автор

You can pry push() & slice() from my cold, arthritic, dead hands... New array by spread is neat, though. Also, who's concerned about preserving the value of a pseudo primitive in practice, anyway?

CalShoemaker
Автор

Which is funny because Redux Toolkit actually encourages it.

kozmicluis
Автор

Why? How is the memory efficiency compare to destructive way?

domw
Автор

To all juniors out there, pros use Immer.

beganovich
Автор

Based on my experience I really dont like old people teaching since my prof in college are way too textbook and doesnt keep updated with their knowledge they also dont like being told that there are better ways to do it and pointing them wrong 😂 but I dang I was very wrong about it especially you, since you are way to updated with all new frameworks features etc. You are like a cool old guy that is very informative doesnt stop learning and very easy to watch with pleasing voice that makes it easy to understand new concepts etc. Love your youtube shorts and watching your videos that explains new features, frameworks in typescript/js world. Fireship is popular because explaining with memes is entertaining but both are my favorite go to influencers when it comes to new contents about frameworks, features and concepts.

lapulapucityrider
Автор

Can you put link here please? I couldn't find the link and it would be really useful for me

nicolasmayorga
Автор

Those garbage men working overtime these days.

MobiusCoin
Автор

s/it's/its/
s/cghange/change/

I don't like the term 'destructive' .. it's not destroying anything, it's changing a value within the existing array. Which react won't notice, of course, but that doesn't make it 'destructive'..

Otherwise, Thanks!

HKnSLK