LoginSignup
1
1

More than 1 year has passed since last update.

Symbolとは

Posted at

Simbolとは

プロパティーの重複を避けるために、必ず一意の値を返す変数。

const s = Symbol('hello');
const ss = Symbol('hello');
console.log(s === ss);
//出力結果 false

一見trueが出力されると思いきや
異なる値がこのSymbolに格納されているということがわかる。

Symbolに取る引数の文字列というのは、あくまでこのこのsymbolに名前をつけているだけであり、同じSymbolを生成しているわけではない。呼び出しごとにSymbolの値は変わる。

1
1
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
1
1