JavaScript objects have a hidden property [[Prototype]]
& it is called prototype.
There are many ways to set [[Prototype]], one of them is __proto__
:
Now when we log the property eagle.fly
it will log true.
The references can be made to multiple levels.
It has some limitations:
- References can’t be circular. JavaScript will throw an error if we try to assign
__proto__
in a circle. - The value of
__proto__
can be only object of null. No other value is allowed.
Note: this blog is under progress