tc39 / ecma262

Status, process, and documents for ECMA-262
https://tc39.es/ecma262/
Other
14.85k stars 1.27k forks source link

Typo in Note 1 of Array.prototype.lastIndexOf #3314

Open declval opened 2 months ago

declval commented 2 months ago

The last sentence of Note 1 in Array.prototype.lastIndexOf reads: If the computed index is less than or equal to +0𝔽, -1𝔽 is returned.

If I understand it correctly it should be instead: If the computed index is less than +0𝔽, -1𝔽 is returned.

If e.g. the length of the array is 2 and the optional fromIndex is -2 the computed index would be 0 and the loop at step 8 executes once comparing searchElement with the first element of the array, potentially returning 0 if they are the same according to the IsStrictlyEqual algorithm.

michaelficarra commented 2 months ago

Confirmed. This is probably an error from trying to copy the prose from the analogous note in indexOf. While we're here, we should probably take this prose out of the notes. This is exactly the kind of thing we typically put in the summary of a built-in or AO.