Skip to content
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

Review requests for MDN docs for TC39 proposals #9

Open
littledan opened this issue Jan 10, 2019 · 6 comments
Open

Review requests for MDN docs for TC39 proposals #9

littledan opened this issue Jan 10, 2019 · 6 comments

Comments

@littledan
Copy link
Member

MDN is a wiki, so writing articles there can feel like sending it to a black hole.

In this thread, let's post links to our recently posted MDN articles or edits about TC39-related topics, so that others can see them and comment on them.

Use a 👍 GitHub react if you read something and it looks good, or @-mention the poster of the request to give review comments.

It's not clear whether a GitHub thread will work or something smaller like email threads would be better; let's not hesitate to switch to something else if this doesn't work out.

cc @sarahgp @shwetank @romulocintra @bkardell @chicoxyzzy @neilkakkar @vaidehijoshi @pipobscure

@bendtherules
Copy link

bendtherules commented Jul 11, 2020

This issue looks empty, so let me start with something 😀.

In Array.prototype.concat mdn page, it does not talk about ArraySpeciesCreate behavior. ArraySpeciesCreate uses the same constructor as "this" to create the output array.

That is, if "this" is actually created from a subclass of Array - then what will be the type of the returned array. Say, Array1 extends Array and then we do (new Array1()).concat([1]) - then is output instanceof Array1?

Should we add this information to that page? Or is that more of a Implementation detail?
I guess this behavior is also applicable for some other Array methods, not just concat.

@ljharb
Copy link
Member

ljharb commented Jul 11, 2020

It might be being removed soon, so that’s probably best not to document for now.

@bendtherules
Copy link

It might be being removed soon

So, what is likely to get removed? Constructor reuse and @@species? It will then return a plain array?

Also, one more nitpick from the description -

The concat method creates a new array consisting of the elements in the object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array). It does not recurse into nested array arguments.

Is it clear enough from the text that - both "this" and other arguments will be treated in this way (either spreaded or appended as whole) ?
To me, it reads like this behavior is only applicable for arguments.

@ljharb
Copy link
Member

ljharb commented Jul 11, 2020

Yes.

“the elements in the object in which it is called” is the receiver (the this), and then each argument is processed as described.

@bendtherules
Copy link

bendtherules commented Jul 11, 2020

But then, what happens if the receiver itself is not spreadable? Like Array.prototype.concat.call({a:1} , array2);

From what i understand - the whole list of (receiver + all arguments) is treated in the same way - spread or append, not just the arguments.
But mdn doc says, this applies for only arguments.

Which understanding is wrong?

@ljharb
Copy link
Member

ljharb commented Jul 11, 2020

The same thing if an argument is not spreadable. They’re all treated the same, but MDN isn’t going into detail about the obscure edge case of using .call on a non-array.

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

No branches or pull requests

3 participants