Thursday, 12 September 2013

Variable Affecting It's Parent Variable

Variable Affecting It's Parent Variable

The title might seems weird, but I don't really know how to describe this
situation as I'm a beginner in JavaScript,
Here's the code :
a={};
var b=a;
b['a']='x';
console.log(a);
the result will be:
Object { a="tes"}
shouldn't it be a blank object because I set 'x' to variable b only ?

No comments:

Post a Comment