Home > front end >  A simple Javascript interview questions!
A simple Javascript interview questions!

Time:12-01

why a.x does not exist, but b.x exist? Results: why?



CodePudding user response:

If the variable is before the existing memory heap ({n: 1}) attributes (no matter ever existed before, no existence is created and then point to null) first, and then use the heap object 2} {n: the property orientation, just explained why b.x point to 2} {n:, because just b also points to the memory in the heap, and a.x undefine for execution a.x=a={2} n:, a.x is not operating a new memory {2} n: attributes, so a.x undefine, js in performing a=b (assignment expression), put on the left side of the variables of the stack (could be in the heap variable a.x) set, then the assignment, so a.x=a={2} n: and a=a.x={2} n:, because the variables on the left have been identified for the
Conclusion:
In even while waiting for the assignment, on the left side of the variable assignment are all at the same time (no order), execute the assignment moment which object memory operations, such as a.x={2} n: at this time of a object is {n: 1}, and a={2} n: only a variable (memory) rather than the object, it should be well understood

CodePudding user response:

A good understanding
  • Related