filmov
tv
Why is Cloning Arrays and Objects in JavaScript so Difficult | Explained

Показать описание
Cloning of Arrays and Objects in Javascript/Typescript is a confusing concept, especially for beginners. However, it is not that difficult.
The logic behind cloning an object is that primitives are passed by value, whereas objects and arrays are passed by reference.
There are two ways to clone a javascript object by value:
2. Spread Operator (...)
You can also convert your object into a string and back to an object using JSON.stringify() and JSON.parse().
--
--
--
Chapters:
0:00 Intro
0:28 Why is it difficult?
0:56 Here's the problem
2:41 Spread operator
3:17 Nested objects
3:34 Cloning nested objects
5:18 Outro
--
If you’re just as crazy for tech as us, we’d love to keep you around. You can also find us at:
We’ll be waiting to catch up with a fellow techie:)
--
The logic behind cloning an object is that primitives are passed by value, whereas objects and arrays are passed by reference.
There are two ways to clone a javascript object by value:
2. Spread Operator (...)
You can also convert your object into a string and back to an object using JSON.stringify() and JSON.parse().
--
--
--
Chapters:
0:00 Intro
0:28 Why is it difficult?
0:56 Here's the problem
2:41 Spread operator
3:17 Nested objects
3:34 Cloning nested objects
5:18 Outro
--
If you’re just as crazy for tech as us, we’d love to keep you around. You can also find us at:
We’ll be waiting to catch up with a fellow techie:)
--