How to create Deep copy of an Array/Object in Angular? - Top Angular Interview Questions

preview_player
Показать описание
About this video:
This video highlights the various ways to create a deep copy of an object/array in Javascript. It talks about deep copy vs shallow copy in angular. The 3 ways to create a deep copy are:
1) Using JSON.parse and JSON.stringify
2) Using the ES6 spread operator
3) Using clonedeep within the lodash library

Watch this video if you all want to know the commonly asked interview questions in Angular and have been searching for it all this while. This is the fourth episode of a multi-part series where in I will be going over a plethora of topics related to Angular. Stay Tuned! Do Like, Share and Subscribe if you enjoyed the content and found it helpful for your projects. Cheers!

Video Chapters
-----
Intro: (0:00)
Shallow Copy vs Deep Copy: (0:15)
3 ways to create a deep copy in angular: (1:58)
Conclusion: (4:33)

#angular #tutorials #interview

Subscribe for more videos:

If you want to crack Angular Interviews, do watch:

Let’s connect:

#angular #tutorials #course #learn #interview #questions #advanced #concepts #english #deep #copy #typescript #json #stringify #es6 #spread #operator #lodash #shallow #copy
Рекомендации по теме
Комментарии
Автор

Hey Prasad, just wanted to let you know that [...someArray] doesn't really create a deep copy, but rather a shallow copy. It does make a copy of the array, which is stored in a new memory location that is distinct from that of the original array. However, each element of the array is still a reference to an object. So editing originalArray[0] will also edit newArray[0] and vice versa.

mattthomas
Автор

hi, thanku for this but I've some questions. What is the best approach according to you ? when to use what ?
and if the first 2 ways work fine then why do we need to install a library ?

av
visit shbcf.ru