Avoid JavaScript Object Cloning Issues

preview_player
Показать описание
A quick lesson on the pitfalls of using ... to shallow clone objects in JavaScript.

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

We could use structuredClone to create deep copy

Harish-rzgv
Автор

The real mistake was initially setting the genre to Classical when it should be Baroque

GoodHomeVideos
Автор

That's why immer js like libraries are immensely helpful.

avinashthakur
Автор

Your choice of examples make it way more fun to learn👌

sahej
Автор

Thank you! Very helpful! You are definitely so so underrated, you deserve so much more attention, thank you so much for making these helpful and informative videos! Keep it up please

tonyartz
Автор

Learn something new everyday, especially when I watch your content!

matthewjwhitney
Автор

Not really a copy, but destructured assignment to a new object.

giovany
Автор

Love your rap skills. From bach to rock😂😂

jonathanjohnson
Автор

ThePrimeagen said in one of his streams to not create copies (via spread operator) but mutate the original array. He even went over an article highlighting how Tanstack Table was made faster by removing the spread operator in favor of .push(). So I assumed the spread operator made a deep copy.
But according to you (and MDN) that's not true.

EhteshamShahzad
Автор

Thanks you so much. Now, I can understand why people are using Redux + ImutableJS. But I heard from my co-worker that ImmutableJS can improve app performance as well (avoid unnecessary re-render). I don't know how ?

nangquy
Автор

Create a deep copy using - const new_obj =

mindbodyps
Автор

Okay, shallow copy and deep copy understood

sweatypotato
Автор

What the hell. How did youtube know i was having a bug that probably has to do with this.

dankeykang
Автор

I failed an interview partly because of this a day ago

dogik
Автор

It’s also a costly operation when you have a lot of data

seanki
Автор

How to handle the deep copy of the obj if the obj has functions?

let user1 = {
name: "Foo",
calculateAge: function() { return 20;}
}
If I use let user2 = then user2 will miss the function. Any javascript solution without using any library such as lodash?

krishnayallapanthula
Автор

What is the name of the extension that prints out Rock in the same row?
I know of quokka, but is there a free version? please share! Tia

loganw
Автор

What if there are many a lot of objects inside objects. Should we go to each level and use spread operator?

webdev_telugu
Автор

Stringify then parse could do the work

mbahmusalto
Автор

Interesting, that’s why Rust is using the ownership principle, because this here is very annoying and not trivial to spot

simonkraemer