0

I have following js codes:

var a = {x:1, y:2};
console.log(a);
console.log(a.x);
a.x = 0;
console.log(a);
console.log(a.x);

Outputs (in firefox, chrome):

Object x: 0 y: 2
1
Object x: 0 y: 2
0

Why is a.x 0 in first console.log? It is not assigned to 0 yet.

SantK
  • 29
  • 5

0 Answers0