Copying Arrays (deep and shallow) - Beau teaches JavaScript

preview_player
Показать описание
Shallow copy arrays using slice and the spread operator. Deep copy arrays using JSON.stringify.

⭐JavaScript Playlists⭐

-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

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

I really like how you keep the video length short and relative to the topic at hand.

steveoliverc
Автор

You’re awesome. Thank you so much. I was having such an issue with a nested array. I couldn’t understand why it keep muting the original array. Thank you again and keep up the great work.

mrcaf
Автор

Beau is legit the fastest code typer in history.

BonzoBouse
Автор

Dude... I'm already loving you so much. I spent an hour racking my brains with this at work and now it's finally settled.

VinyciusOliveira
Автор

Beau this is the best explanation of shallow and deep copy I have seen, thanks alot!!

Hi-
Автор

Excellent job. I particularly appreciated the part about pointers and arrays & objects within arrays.

AnnaMaria-orse
Автор

Unfortunately, it removes any functional property of the object.
Example:
const names = [
{ value: "name",
getName : function(){ return this.value }}
];
const names2 =
names2[0].value = "modified";
names[0].getName()
names2[0].getName(); // this line will throw the error getName() isn't a function.

anuragbhagsain
Автор

you just saved my life i was keep facing the issue for last couple of days...

SumanDutta
Автор

Very helpful video with detailed explanation

sunilkumarpandab
Автор

That was really helpful, was stuck with this
Thanx ❤️

pam-abhivyakti
Автор

This was so informative. Thanks a lot!

hananfadah
Автор

In terms of performance, worth doing this conversions instead of a recursive deep copy function?

joaofnds
Автор

Is using JSON better in performance than manually copying each item for a deep copy?

logixindie
Автор

damn... finally found where is my bug thanks to this video... the way this thing work is completely absurd !

Grahfx
Автор

what about using map()? i actually have an instance where i'm working with a nodelist of objects in the Dom.

Meleeman
Автор

I don't know why I found it funny that the solution was simply to turn it into JSON and back into Javascript. The creativity of some people 👌

keifer
Автор

how to copy 2 arrays in to 1 array i have an exam thanks for help

AliNjaff
Автор

this is also an alternative: Array.from(original) But it's not supported by IE

GabrielVasile
Автор

Hi, should I learn from FCC if I'm interested in becoming an Android developer?

HueJakes
Автор

you don't need a 0 in original.slice(0) since 0 is the default

GabrielVasile