1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JavaScriptで任意のカスタムオブジェクトを作る方法

Last updated at Posted at 2025-02-14

概要

カスタムオブジェクトは「Object.create(null);」と、プロパティ追加で作成していきます。

定義

function empObj(){
    return Object.create(null);
}

使用例

const o = empObj();
o.aaa = 1;
o.bbb = 2;
console.log("o.aaa + o.bbb = " + (o.aaa + o.bbb));

表示結果

o.aaa + o.bbb = 3
1
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?