Skip to content

Instantly share code, notes, and snippets.

var songs = new Set ();
musicas.add ('musica1');
for (var music of songs) {
 console.log (music); // music1
}
var songs = new Set (['music1', 'music2']);
music.delete ('music1');
for (var music of songs) {
 console.log (music); // music2
}
var songs = new Set ([
 'song1', 'song2', 'song3'
]);
songs.clear ();
for (var music of songs) {
 console.log (music); // anything
}
var songs = new Set(['song1']);
if (songs.has ('song1')) {
 console.log ('already in the list!');
}
// is already in the list!
var songs = new Set ([
 'song1', 'song1', 'song1'
]);
var songsAmount = songs.size;
console.log ("There are" + songsAmount + "songs in the list");
// There are 3 songs in the list
var song1 = {
 title: 'Love has no rollback',
 author: 'SQL'
}
var songs = new WeakSet ([song1]);
console.log (songs);
// WeakSet {Object {title: "Love has no rollback", author: "SQL"}}
var song1 = {
 title: 'Love has no rollback',
author: 'SQL'
}
var songs = new Set ([song1]);
console.log (songs);
song1 = null;
// examples
var object = {}; // object
var number = 1; // number
var name = "Keys"; // string
var list = [1,2,3]; // list
const arrayVar = [];
for (var i = 1; i <5; i ++) {
 arrayVar.push (function () {
 console.log (i);
 });
}
const arrayLet = [];
for (let i = 1; i <5; i ++) {
 arrayLet.push (function () {
 console.log (i);
 });
}