Is there any way I can make a deep copy of a variable? (NOT object). Example:
var a = ["String", "string"];
var b = a;
b.splice(1, 1);
b = a;
In my example, a
isnt supposed to change, I want to use it later for restoring b
. (As showed in code above).
I understand that =
just makes a new reference, hence the question: is there any other way I can make a deep copy instead of a reference?
Want to note that I can't be using any library, I've found answers suggesting jQuery and such, but I cannot use this.