1// The '=' operator in javascript can serve the purpose of shallow vs
2// deep copy.
3
4// The '=' operator in javascript will assign deep copy to primitive
5// data types. For example:
6let a = 10;
7let b = a;
8b = 4;
9console.log(a);
10// Output: 10
11console.log(b);
12// Output: 4
13
14
15// The '=' operator in javascript will assign shallow copies to
16// non-primitive data types. For example:
17let a = ['a','b','c','d','e','f','g'];
18let b = a;
19b.pop();
20console.log(a);
21// Output: ["a","b","c","d","e","f"]
22console.log(b);
23// Output: ["a","b","c","d","e","f"]
1/*
2
3Search Results
4Featured snippet from the web
5A deep copy means that all of the values of the new variable
6are copied and disconnected from the original variable.
7A shallow copy means that certain (sub-)values are still connected
8to the original variable. To really understand copying,
9you have to get into how JavaScript stores values
10
11
12/*