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

Missing "TypeError: Cannot convert undefined to object" #36355

Closed
Rudxain opened this issue Oct 15, 2024 · 1 comment
Closed

Missing "TypeError: Cannot convert undefined to object" #36355

Rudxain opened this issue Oct 15, 2024 · 1 comment
Labels
closed: duplicate This issue or pull request already exists Content:JS JavaScript docs

Comments

@Rudxain
Copy link
Contributor

Rudxain commented Oct 15, 2024

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors

What specific section or headline is this issue about?

List of errors

What information was incorrect, unhelpful, or incomplete?

Missing error message

What did you expect to see?

"TypeError: Cannot convert undefined or null to object", which is the full message on NodeJS

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

// fine
([].sort)();

(1 && [].sort)();
// Uncaught TypeError: Cannot convert undefined or null to object
//    at sort (<anonymous>)

let s = [].sort;
s();
// Uncaught TypeError: Cannot convert undefined or null to object
//    at sort (<anonymous>)

From what I understand, this happens because the this binding on [] is reset to undefined

MDN metadata

Page report details
@Rudxain Rudxain added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Oct 15, 2024
@github-actions github-actions bot added the Content:JS JavaScript docs label Oct 15, 2024
@Josh-Cena
Copy link
Member

In Firefox the error message is "TypeError: can't convert undefined to object", so that would be what we document, but yes we are missing this. It can happen any time undefined or null is being coerced to an object. I am closing this though because we have a whole project for completing the errors reference: mdn/mdn#505 thanks for bringing this up!

@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: duplicate This issue or pull request already exists Content:JS JavaScript docs
Projects
None yet
Development

No branches or pull requests

2 participants