JS: Dot Notation and Prototype Chain
Dot Notation a.b.c Does Not Show Prototype Chain
When you see a.b.c.d in JavaScript, it has very different meaning than Java or Python, Ruby. This is a major point of confusion.
In Java, in a.b.c.p, the dot means parent/child except the last dot, is object/property.
So, a is parent of b,
b is parent of c,
and c is the object that has member p.
In JavaScript, dot always means a relationship between a object and a property key name. There's no direct syntax to show parent chain.
in JavaScript, when you see a.b.c.d, the left/right thing of any dot has a object/property (own or inherited) relationship.
It's parsed like this: (((a).b).c).
- Object
ahas property keyb - Object
a.bhas property keyc - Object
a.b.chas property keyd
The value of the property, such as a.b, could be any object, having nothing to do with any of the object a or a.b or a.b.c.
For example, the expression Array.prototype.slice.call:
- The parent of
Array.prototype.slice.callisFunction.prototype. - The parent of
Array.prototype.sliceisFunction.prototype. - The parent of
Array.prototypeisObject.prototype. - The parent of
ArrayisFunction.prototype.