How do the objects?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
var a = "t";
var b = {};
a = b;
a.x = 7;
b.y = "m";
a.y = b.x;
b.x = "p";

console.log(a);
console.log(b);

Tell me on what basis the assignment. Don't understand why the output in x is 'p' in both objects, and y the number 7, also in both sites.
by | 7 views

1 Answer

0 like 0 dislike
Because a and b are references to the same object.
Read more here.
by

Related questions

0 like 0 dislike
2 answers
asked May 21, 2019 by pilolin
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 12, 2019 by campus1
110,608 questions
257,186 answers
0 comments
35,430 users