[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Set/Set [Back]  [Original]

Set() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Set()

Baseline

20157

Set() Set

const set = new Set([1, 2, 3, 4, 5]);

console.log(set.has(1));
// : true

console.log(set.has(5));
// : true

console.log(set.has(6));
// : false

js
new Set()
new Set(iterable)

: Set() new new TypeError

iterable

Set

null Set

Set

Set

js
const mySet = new Set();

mySet.add(1); // Set [ 1 ]
mySet.add(5); // Set [ 1, 5 ]
mySet.add(5); // Set [ 1, 5 ]
mySet.add("some text"); // Set [ 1, 5, 'some text' ]
const o = { a: 1, b: 2 };
mySet.add(o);

ECMAScript 2027 LanguageSpecification
# sec-set-constructor


Web Proxy Viewer  |  New URL  |  Original Page