ES6 Tutorial #9: Shallow vs Deep Copy| Interview Question| Modern Javascript 2021

preview_player
Показать описание
In this video, I have explained in detail, how to copy
javascript object and what is shallow and deep copy in javascript

Shallow copy is also identified by pass by Reference , when you
make a copy of original variable into another variable(copied) by using
assignment operator(=), that time only the reference address
of original variable is copied into another variable instead of original
values.
So at last both variables refer to the same value. So when you make any changes in
new variable if will also mutate or change the original variable

Deep Copy:
Deep copy is also identified by pass by Value, when you make a copy of
variable into another variable by using assignment operator, at that time
all the values(object, arrays) along with reference address of original variable
is copied into another variable.
At last, both variables refer to different referenced
values. So when you make any change in new variable it won't mutate the original variable.

I have one assignment at the end of the tutorial.

Please support my channel,🙏 by showing your love❤️ by liking and sharing my video, so that I can reach to more people and can help them too.
Watch my Angular playlist :

Follow me:

For more such interesting videos, please subscribe to my channel and stay connected.

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

Awesome explained each and every concept.... Thank you...

CodeWithJamil
Автор

thanks sis💪🏻💯 i was struggling to understand deep vs shallow copy and watched many yt videos but you made it easy for me and now i understand it you're a lifesaver fr fr👌✨

dragons.
Автор

Your videos are really informative and we can understand the concepts very clearly. Please add videos on ngRx and cookies in angular

anjusreedharan
Автор

Thank You So much Mam.
After witching other youtubers video I don't understand what is Shallow copy & Deep copy
But Mam your video is so helpful me to understand the concept and all methods in Easy Way.
Again Really Really Thank You!

EcomBusiness
Автор

Damn girl!! Those videos are super helpful!!!! Can't thank you enough!!!

akiratoriyama
Автор

Well this was a deep explanation for my shallow js knowledge. Great video thanks

kunalrajput
Автор

Thank you, Clean and clear explanation

rajeshkolluri
Автор

Thanks for this informative and easy to understand video..

anupb
Автор

Awesome explanation , thank you so much

chanduBoddu
Автор

thankyou mam for making my concept clear

apurvakumar
Автор

When to use shallow copy and deep copy ? Can you explain about this difference?

kotireddy
Автор

Awesome Series :) (y)
..
In this case if I want to update Country in copied Object ?
I am trying to update in copiedvalue country value as 'US' (for example), its creating a new key value with same pair .

SAAMY_
Автор

Nicely explained..understand the concept well..just a confusion, Object.assign() is giving partial deep copy, JSON.stringify() also giving partial deep copy...and use of spread operator is giving complete deep copy...so my question is which method is giving shallow copy...is shallow copy same as just assigning one object to another object or something else?

anupb
Автор

With the help of this you can easily achieve the deep copy

mithunkumar
Автор

how much javacsript we would learn to land a job as a frontend developer please help me its an emergency

Looser_alpha
Автор

i can able to do foe nested and simple objects
FOR
var obj = [{ x: 1 }, {y: 2}];
var deepCopy = _.cloneDeep(obj);
// Changing orignal value
obj[0].x = 10;

// Values after changing original value
console.log("After changing original value");

console.log("Original value ", obj);

console.log("Deep Copy value ", deepCopy);

OUTPUT

Original value [ { x: 10 }, { y: 2 } ]
Deep Copy value [ { x: 1 }, { y: 2 } ]

apurvakumar