tc39/js-outreach-groups

Review requests for MDN docs for TC39 proposals

littledan opened this issue · 6 comments

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

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.

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

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.

Yes.

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

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?

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.