I try to create a simple example in order to see what is the problem of cloning in JS and what function I can use in order to make it work properly. I try to use an example that I have an object l
with some variables and assign this object to k
(l=k
) expecting that when I will type l.age
and k.age
I will see something different in order to see how the cloning is working. However, when I test these 2 calls in console I can't see any problem, both of them have the same value. Is there anything I make wrong in order to see the cloning issue in JS?
Here what I try to do. I try to have an object l:
<script>
var l = {
firstName : "John",
lastName : "Doe",
age : 50,
eyeColor : "blue"
};
k = l;
</script>
My problem is not only I try to use a cloning method however I try to understand the problem on hand first before I go a step forward on how to solve it using an efficient cloning method.