0

opener` in my child window by the parent window.

in my parent window code is

var a ={"test":""};
var b=a;

in my child window my code is

top.opener.b.test="set by child";

Now i close this child window

now when i see a.test it gives me set by child

i don't know when i update b why it is update in a

So How can I reset b by a

Please help me guys.

Thanks ...

Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55
  • http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language – adeneo May 23 '14 at 11:42

1 Answers1

2

Because b is not actually a copy of a, it is a reference to a. This means that when you reference b you're really referencing a.

More info on how objects work in JavaScript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects

Jon Snow
  • 3,682
  • 4
  • 30
  • 51
  • then how can i pass copy of a in b – Rituraj ratan May 23 '14 at 11:41
  • This question has been answered a lot, this is the most popular answer: http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object Also different frameworks and libraries have methods of cloning an object. – Jon Snow May 23 '14 at 11:42