set
-
[Javascript] Set 객체언어/Javascript 2022. 6. 7. 23:53
/* mdn web docs에 나와있는 예제 */ const mySet1 = new Set() mySet1.add(1) // Set(1) { 1 } mySet1.add(5) // Set(2) { 1, 5 } mySet1.add(5) // Set(2) { 1, 5 } mySet1.add('some text') // Set(3) { 1, 5, 'some text' } const o = {a: 1, b: 2} mySet1.add(o) mySet1.add({a: 1, b: 2}) // o is referencing a different object, so this is okay mySet1.has(1) // true mySet1.has(3) // false, since 3 has not been added to..