You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey Addy, I've been reading your Javascript design patterns online, and I think it's a marvelous book. I respect you a lot, so don't think that I'm attacking you ( or your knowledge of Javascript ) in any way, shape or form. In fact, I really do admire your knowledge.
In the "Constructors with Prototypes" subsection you say this:
Functions, like almost all objects in JavaScript, contain a "prototype" object. When we call a JavaScript constructor to create an object, all the properties of the constructor's prototype are then made available to the new object.
I don't think that this is right. I think that the "prototype" property actually points to the prototype object of all objects instantiated by the constructor, but not the constructor's prototype itself.
I did a test today in Developer Tools, and this really seems to be the case.
Take this for an example; we have a constructor function ( I'm going to use your example if you don't mind ):
Now, if I check the prototype of this function in Chrome Developer Tools,
Car.__proto__
... I will get this:
functionEmpty(){}
, which is the uppermost prototype of all functions. Now, I can instantiate the Car 'class':
varmyFord=newCar('My Ford',2015,0);
, and then see its prototype:
myFord.__proto__
...then I get this:
Car{}
So, I don't think that the function's "prototype" property actually points to it's own prototype; rather, it point's to the prototype of all objects that were instantiated by it.
The text was updated successfully, but these errors were encountered:
Hey Addy, I've been reading your Javascript design patterns online, and I think it's a marvelous book. I respect you a lot, so don't think that I'm attacking you ( or your knowledge of Javascript ) in any way, shape or form. In fact, I really do admire your knowledge.
In the "Constructors with Prototypes" subsection you say this:
I don't think that this is right. I think that the "prototype" property actually points to the prototype object of all objects instantiated by the constructor, but not the constructor's prototype itself.
I did a test today in Developer Tools, and this really seems to be the case.
Take this for an example; we have a constructor function ( I'm going to use your example if you don't mind ):
Now, if I check the prototype of this function in Chrome Developer Tools,
... I will get this:
, which is the uppermost prototype of all functions. Now, I can instantiate the Car 'class':
, and then see its prototype:
...then I get this:
So, I don't think that the function's "prototype" property actually points to it's own prototype; rather, it point's to the prototype of all objects that were instantiated by it.
The text was updated successfully, but these errors were encountered: