Skip to content

Update article.md #1420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2019
Merged

Update article.md #1420

merged 1 commit into from
Oct 11, 2019

Conversation

paroche
Copy link
Collaborator

@paroche paroche commented Oct 7, 2019

and -> or, methods -> methods

I also have a question on the subject of this sentence (should this be a separate discussion entry?):
In the "Extending built-in classes" article, in the "No static inheritance in built-ins" subsection, one finds:

"But built-in classes are an exception. They don’t inherit statics from each other.

For example, both Array and Date inherit from Object, so their instances have methods from Object.prototype. But Array.[[Prototype]] does not reference Object, so there’s no Array.keys() and Date.keys() static methods."

In the "Extending built-in classes" article, in the "No static inheritance in built-ins" subsection, one finds:

"But built-in classes are an exception. They don’t inherit statics from each other.

For example, both Array and Date inherit from Object, so their instances have methods from Object.prototype. But Array.[[Prototype]] does not reference Object, so there’s no Array.keys() and Date.keys() static methods."

This is a subject of some curiosity for me. Through a little testing, I believe I have found that, in fact Array.[[Prototype]] DOES, however, reference Function.prototype, i.e. Array.__proto__ === Function.prototype (true). (As does Date.[[Prototype]]). Is there someplace where this is explained? (Preferably in a way an intelligent 11-year-old could understand?).

and -> or, methods -> methods

I also have a question on the subject of this sentence (should this be a separate discussion entry?):
In the "Extending built-in classes" article, in the "No static inheritance in built-ins" subsection, one finds:

"But built-in classes are an exception. They don’t inherit statics from each other.

For example, both Array and Date inherit from Object, so their instances have methods from Object.prototype. But Array.[[Prototype]] does not reference Object, so there’s no Array.keys() and Date.keys() static methods."

In the "Extending built-in classes" article, in the "No static inheritance in built-ins" subsection, one finds:

"But built-in classes are an exception. They don’t inherit statics from each other.

For example, both Array and Date inherit from <code>Object</code>, so their instances have methods from <code>Object.prototype</code>. But <code>Array.[[Prototype]]</code> does not reference <code>Object</code>, so there’s no <code>Array.keys()</code> and <code>Date.keys()</code> static methods."

This is a subject of some curiosity for me. Through a little testing, I believe I have found that, in fact <code>Array.[[Prototype]]</code> DOES, however, reference <code>Function.prototype</code>, i.e. <code>Array.__proto__ === Function.prototype</code> (<code>true</code>). (As does <code>Date.[[Prototype]]</code>). Is there someplace where this is explained? (Preferably in a way an intelligent 11-year-old could understand?).
@iliakan
Copy link
Member

iliakan commented Oct 10, 2019

The information about native prototypes is here: http://javascript.info/native-prototypes

Should we cross-reference it maybe?

@paroche
Copy link
Collaborator Author

paroche commented Oct 10, 2019

I'm pretty familiar with that article. I meant somewhere where the connections I noted are explained -- why Array.proto === Function.prototype and Date.proto === Function.prototype. Makes it look like Function may be the internal constructor for Array and Date. I don't think that article covers that.

@iliakan
Copy link
Member

iliakan commented Oct 10, 2019

That's simply because Array and Date are functions. Should we add more explanations about that?

@iliakan iliakan merged commit db0407b into javascript-tutorial:master Oct 11, 2019
@paroche
Copy link
Collaborator Author

paroche commented Oct 13, 2019

Yes, and Function and Object are also functions.
And therefore, strangely at first, kind of, Function.__proto__ === Function.prototype.
And, unsurprisingly at this point, Function.constructor === Function.prototype.
And Object.__proto__ === Function.prototype, but Function.prototype.__proto__ === Object.prototype.

Kind of brings to mind the old Country song "I am my own Grandpa".
https://www.youtube.com/watch?v=qu_Y1wQ923g

Also, Object, for instance, has methods of its own, while Function does not (except in Function.prototype).

Personally, I'm getting a sense of it, but a bit more explanation in a skipable section could be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants