|
|
@ -3,12 +3,15 @@ Set is another data structure in JavaScript which is similar to `Array` but the |
|
|
|
```js |
|
|
|
```js |
|
|
|
const roadmap = new Set(); |
|
|
|
const roadmap = new Set(); |
|
|
|
roadmap.add('JavaScript'); |
|
|
|
roadmap.add('JavaScript'); |
|
|
|
|
|
|
|
roadmap.add('JavaScript'); |
|
|
|
|
|
|
|
|
|
|
|
roadmap.add('dynamic'); |
|
|
|
roadmap.add('dynamic'); |
|
|
|
roadmap.add(1995); |
|
|
|
roadmap.add(1995); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(roadmap.size); // 3, because the value 'JavaScript' is already present in the set |
|
|
|
console.log(roadmap.has('JavaScript')); // true |
|
|
|
console.log(roadmap.has('JavaScript')); // true |
|
|
|
|
|
|
|
|
|
|
|
roadmap.delete(1995); |
|
|
|
roadmap.delete('JavaScript'); |
|
|
|
console.log(roadmap.has(1995)); // false |
|
|
|
console.log(roadmap.has('JavaScript')); // false |
|
|
|
console.log(roadmap.size); // 2 |
|
|
|
console.log(roadmap.size); // 2 |
|
|
|
``` |
|
|
|
``` |
|
|
|