I have seen this question being asked multiple times but I have a specific example to clarify.
var a = {animal: 'cat'}; var b = a; a.animal = 'bear'; Here, I see b.animal will give an output "bear". Why is that? And how do I retain the original reference "cat" for variable b?
atob, but they both point at the same object. If you want to copy the object, then you need to copy each property of that object to a new object.bis a copy ofa, but they both still refer to the same object. Is JavaScript a pass-by-reference or pass-by-value language?