keepup-ECMAScript
CtrlK
  • About
  • Proposal
    • using
    • Temporal
  • ES2025
    • Promise.try
    • Sync Iterator helpers
    • Import Attributes
    • JSON Modules
    • New Set Methods
    • RegExp Modifiers
    • Duplicate named capture groups
  • ES2024
    • Resizable and growable ArrayBuffers
    • RegExp v flag with set notation + properties of strings
    • Atomics.waitAsync
    • Well-Formed Unicode Strings
    • array grouping
    • Promise withResolvers
  • ES2023
    • Symbols as WeakMap key
    • Hashbang Grammar
    • Array.findLast, findLastIndex
    • 配列の非破壊操作
  • ES2022
    • Private class fields
    • Regexp match indices
    • Top-level await
    • Private fields in-in
    • Array.at
    • Object.hasOwn
    • Class static block
    • Error cause
GitBook提供
このページ内
  • Example
  • Link
GitHubで編集
  1. ES2022

Object.hasOwn

オブジェクトの hasOwn が使えるようになった。 従来の hasOwnProperty は外部で書き換えられるため、安全のために Object.prototype.hasOwnProperty().call を使うケースがあったが、これと同じことができるようになった。

Example

const obj = { value:1 };
Object.hasOwn(obj, "value");
// true

Link

LogoGitHub - tc39/proposal-accessible-object-hasownproperty: Object.hasOwn() proposal for ECMAScriptGitHub
LogoJavaScript built-in: Object: hasOwn | Can I use... Support tables for HTML5, CSS3, etc
LogoObject.hasOwn() - JavaScript | MDN
前へArray.at次へClass static block

最終更新 2 年前