0
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?

More than 1 year has passed since last update.

javascript48_属性名と属性値

Last updated at Posted at 2022-02-18

属性名について関数みたいに決まりがあるわけではなく、どんな名前でも使える。
obj.var = "hello"; → 正しい属性名

特殊な属性名を使用したい場合は、.書くのではなく、
下記のように書かなければいけません。
オブジェクト["属性名"] = 属性値;

obj["123"] = 456;
console.log(["123"]);

image.png

属性値はどんなデータ型でもいけます。オブジェクトでもOKです。
image.png

属性がオブジェクトないにあるかどうを確認するには、inを使います。
image.png

0
0
0

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
0
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?