This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var songs = new Set(['song1']); | |
| if (songs.has ('song1')) { | |
| console.log ('already in the list!'); | |
| } | |
| // is already in the list! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var songs = new Set ([ | |
| 'song1', 'song2', 'song3' | |
| ]); | |
| songs.clear (); | |
| for (var music of songs) { | |
| console.log (music); // anything | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var songs = new Set (['music1', 'music2']); | |
| music.delete ('music1'); | |
| for (var music of songs) { | |
| console.log (music); // music2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var songs = new Set (); | |
| musicas.add ('musica1'); | |
| for (var music of songs) { | |
| console.log (music); // music1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var set = new Set ([2,1,2]); | |
| for (const value of set) { | |
| console.log (value); // 2, 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var set = new Set (); | |
| set.add (2); | |
| set.add (1); | |
| set.add (2); | |
| for (const value of set) { | |
| console.log (value); // 2, 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var set = new Set (); | |
| set.add (2); | |
| set.add (1); | |
| set.add (2); | |
| set.showValues(); // [2,1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set () { | |
| var array = []; | |
| this.add = function (value) { | |
| if (array.indexOf (value) === -1) { | |
| array.push (value); | |
| } | |
| }, | |
| this.showValues = function () { | |
| console.log (array); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set () { | |
| var array = []; | |
| this.add = function (value) { | |
| if (array.indexOf (value) === -1) { | |
| array.push (value); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Person = (function () { | |
| var dataPrivate = new WeakMap (); | |
| function Person (name) { | |
| PrivateData.set (this, {name: name}); | |
| } | |
| Person.prototype.getName = function () { | |
| return dataPrivate.get (this) .name; | |
| }; | |
| return Person; | |
| } ()); |