Your edit summary may have tripped up the reviewers
A "valueable comment by the OP" is something that many people will inherently expect is "intended to address the author". "The OP" generally means the person who wrote the question, who in this case is someone else. The comment instead came from the previous editor.
The previous editor did a poor job, but had the right idea
I'm of two minds about that edit. On the one hand, there definitely is an argument that it improves the answer (by using more hygienic scoping). On the other hand, it does so by making use of an optional third argument that the original answerer doesn't seem to have been aware of. This is arguably a different technique, and the one reject vote on that review definitely has merit.
On the third hand, I generally think the site is way too strict about "preserving intent" in edit reviews overall. The point of editing content is to improve it; if the primary problem with content is that it overlooks a simple, clear improvement, then in my view we should have that improvement, even if the author of the content wasn't aware of the potential. I think we've already seen arguments on Meta about adding brief explanations to code-only answers, and some people seem opposed to that on the grounds that the author should be able to express the "intent" that the code is self-evident and doesn't require explanation. I think that's just absurd, and counter-productive.
The only other way we can get that improvement is if someone else writes a completely different answer that looks almost the same but includes the improvement; I posit that this has serious negative consequences in the long run. The only benefit is preserving the sanctity of the competition for reputation among answerers, but this is not by any means the primary objective here. We know that because a) the tour describes Stack Overflow as a library, not as a marketplace of ideas; b) the reputation system creates horrible incentives that are antithetical to all the other goals of the site.
More important than any of that, however: it's really not a good idea to improve code in an answer and then use a comment to explain why the code is an improvement - especially if that "explanation" requires context to treat it as an explanation. Someone who comes across this post later just sees a code-only answer (which is a refinement of a previous code-only answer) that doesn't highlight the improvement in any way, and doesn't say why it's an improvement; plus a comment that points out a true fact about the function used in the code, but again without any actual explanatory power.
Your edit does not resolve this problem
The inserted text:
The 3rd argument of map()
is a reference to the whole array
itself, so in this case myArray
.
does adequately recast the content of the comment. However, it does not explain why we should care. The code can equally well be written without using this argument (by explicitly referring to myArray
, since the anonymous function will close over it).
Since that third argument isn't necessary, the only sensible reason to focus on it is to discuss its use as an alternative (and give a quick justification for why it is an improvement). That more or less requires showing the code both ways.
Oh, I just noticed one more thing. Please do not use inline-code formatting for ordinary programming jargon, except for keywords that would actually appear in the code. Here, while it happens that array
was the name of the parameter used in the example code, it seems clear that you intended to use the word "array" to refer to the type, not to that parameter.
I fixed it
While I support the still ongoing strike, and am not planning to return to full curation capacity any time soon, I have decided that I will continue to read Meta and take a few actions prompted by Meta. Since I have unilateral editing privileges and a reasonable level of understanding of JavaScript (and the ability to verify the code with my browser console), I went ahead and edited to give a brief explanation of what the author's original version does (and how), restate the facts that the author gave about that version, and then show the improvement. Finally I flagged the previous editor's comment as "no longer necessary", since its information is now fully integrated in the edit. I also flagged Paul's comment the same way, because I think my brief explanation of the code heads off the objection that the val
parameter is unused.
Hopefully everyone is happy now.
Addressing these situations more generally
If I had encountered this proposed edit myself while it was still in review (which would require me to be browsing the main site normally), I would most likely have chosen to accept and improve the edit. Even though my version requires significant rewriting, I think that your proposal was a step in the right direction (per the above), and that these should be encouraged even if the change is "small". I agree with your analysis in this Meta question: incorporating useful information from a comment generally shouldn't be problematic.