let a = 10; let b = a; both becomes 10; but if we change b a is not changed unlike array. b = 9; Now, a is 10, but b is 9.
let arr = [1,2,3];
let arr2 = arr;
arr2[1] = 4;
Both has the same value now.
There are several ways to copy an array :
let a = {
name: 'mine',
age: 28
}
let a = b;
b['age'] = 29;
Both has the same value.
There are several ways to copy an object: