-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change should have no user impact. `Object.hasOwn()` replaces `Object.prototype.hasOwnProperty()` in modern JavaScript. Its advantages can be seen in the following code snippet: ``` // Still works even if you overwrite `hasOwnProperty`: const overwritten = { hasOwnProperty: () => true } Object.hasOwn(overwritten, "foo") // => false overwritten.hasOwnProperty("foo") // => true (incorrect) // Still works even if the object has a null prototype: const nullPrototype = Object.create(null) nullPrototype.foo = "bar" Object.hasOwn(nullPrototype, "foo") // => true nullPrototype.hasOwnProperty("foo") // TypeError: nullPrototype.hasOwnProperty is not a function ``` This replaces all uses of `Object.prototype.hasOwnProperty()` with `Object.hasOwn()`. I think this is a useful change on its own, but will also help in a future change.
- Loading branch information
Showing
3 changed files
with
4 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters