close
Skip to content

fix(javascript): call findLast in the TypedArray.findLast example - #45291

Merged
Josh-Cena merged 1 commit into
mdn:mainfrom
rajanpanth:fix/typedarray-findlast-example
Aug 28, 2026
Merged

fix(javascript): call findLast in the TypedArray.findLast example#45291
Josh-Cena merged 1 commit into
mdn:mainfrom
rajanpanth:fix/typedarray-findlast-example

Conversation

@rajanpanth

Copy link
Copy Markdown
Contributor

The interactive example on TypedArray.prototype.findLast calls find() rather than findLast():

const int8 = new Int8Array([10, 0, -10, 20, -30, 40, 50]);
console.log(int8.find(isNegative));
// Expected output: -30

find() returns the first negative element, -10. The documented output -30 is the last one, which is what findLast() returns. So the example both contradicts its own stated output and demonstrates the wrong method on the page that documents findLast.

Verified in Node:

find     : -10
findLast : -30

Changing the call to findLast() makes the example produce the documented -30.

I checked the sibling pages and they are all correct: typedarray/findLastIndex, typedarray/findIndex, typedarray/find, array/findLast and array/findLastIndex each call their own method. This is the only page with the mismatch.

Found by executing every js interactive-example block under files/en-us/web/javascript that carries an // Expected output: comment and comparing the actual scalar output against the documented one: 467 blocks ran, and this was the single value mismatch.

The interactive example on the findLast page called find(), which
returns the first negative value (-10), while the documented output
is -30, the last one.
@rajanpanth
rajanpanth requested a review from a team as a code owner August 23, 2026 14:17
@rajanpanth
rajanpanth requested review from Josh-Cena and removed request for a team August 23, 2026 14:17
@github-actions github-actions Bot added Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@Josh-Cena Josh-Cena left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you!

@Josh-Cena
Josh-Cena merged commit c38c731 into mdn:main Aug 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants