-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
Add Object.hasOwn
to Section 3.7 (Object.prototype methods)
#2606
Comments
That’s great advice if you either polyfill it or support browsers that have it; the Airbnb style guide supports many browsers that do not. |
Okay, thanks, that makes sense. Perhaps
Cheers |
I think we could certainly mention it, as well as link to the polyfill. |
Hello, I created a pr with the proposed changes here: #2610 Cheers |
Hello, it seems that
Object.hasOwn
is now available in most major browsers (https://caniuse.com/mdn-javascript_builtins_object_hasown), so it might be worth adding it to section 3.7.It seems to be recommended as a replacement for
Object.hasOwnProperty
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn), so the section could be changed to something like this:3.7 Do not call
Object.prototype
methods directly, such ashasOwnProperty
,propertyIsEnumerable
, andisPrototypeOf
. eslint:no-prototype-builtins
There is also a rule for this available in eslint 8.5+ (https://eslint.org/docs/latest/rules/prefer-object-has-own).
Cheers
The text was updated successfully, but these errors were encountered: