-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Update index.md #39921
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
base: main
Are you sure you want to change the base?
Update index.md #39921
Conversation
In the "Problematic cases for hasOwnProperty" section, show how hasOwnProperty operates in the two cases as well as Object.hasOwn, and correct the expected output of the Object.hasOwn examples (it was logging the property value, which wouldn't result in true or false. Modified it to just log the Object.hasOwn result).
console.log(foo.hasOwnProperty("prop")) // Uncaught TypeError: foo.hasOwnProperty is not a function | ||
// hasOwnProperty is on the prototype chain, which foo doesn't have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
console.log(foo.hasOwnProperty("prop")) // Uncaught TypeError: foo.hasOwnProperty is not a function | |
// hasOwnProperty is on the prototype chain, which foo doesn't have | |
console.log(foo.hasOwnProperty("prop")); // Uncaught TypeError: foo.hasOwnProperty is not a function | |
// hasOwnProperty is on the prototype chain, which foo doesn't have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer if the comments line up, and as it's in a <pre>
section indenting with spaces should be fine, so I'd like to leave it as I committed it, but happy to change it if you disagree.
…own/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Preview URLs (comment last updated: 2025-06-13 04:31:24) |
The comments wrap on the preview page so might as well combine the indented one with the one on the previous line. Also, missing a ; and a C where there should have been a c.
In the "Problematic cases for hasOwnProperty" section, show how hasOwnProperty operates in the two cases as well as Object.hasOwn, and correct the expected output of the Object.hasOwn examples (it was logging the property value, which wouldn't result in true or false. Modified it to just log the Object.hasOwn result).
Description
Make clearer how hasOwnProperty works in the two cases and make it easy to compare with Object.hasOwn. Also correct the expected output of the console.logs in the Object.hasOwn cases.
Motivation
Makes the difference between Object.hasOwn and hasOwnProperty clearer by having them in the same example, and fix the expected output in the Object.hasOwn cases.
Additional details
Related issues and pull requests
I was going to create an issue but it directed me to do this, so I did. Should I still create an issue, or is this sufficient?