In the following two snippets :
var person = "Kobe";
var anotherPerson = person; // anotherPerson = the value of person
person = "Bryant"; // value of person changed
console.log(anotherPerson); // Kobe
console.log(person); // Bryant
And if we use Object :
var person = {name: "Kobe"};
var anotherPerson = person;
person.name = "Bryant";
console.log(anotherPerson.name); // Bryant
console.log(person.name); // Bryant
The first one logs "Kobe" for the variable anotherPerson
but if anotherPerson has reference to the variable person any changes happened in person should also reflect another person right ?
Can any one explain this in details
Thanks