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
const people = [ | |
{ | |
name: "Joseph", | |
age: 32, | |
gender: "male", | |
}, | |
{ | |
name: "Anna", | |
age: 27, | |
gender: "female", |
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 names = ["Ana", "Mary", "John", "Steban"]; | |
for (var x = 0; x < names.length; x++) { | |
console.log(names[x]); | |
} |
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 names = ["Ana", "Mary", "John", "Steban"]; | |
for (var currentIndex in names) { | |
console.log(names[currentIndex]); | |
} |
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 names = ["Ana", "Mary", "John", "Steban"]; | |
names.forEach(name => console.log(name)); |
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
const people = [ | |
{ | |
name: "Joseph", | |
age: 32, | |
gender: "male", | |
}, | |
{ | |
name: "Anna", | |
age: 27, | |
gender: "female", |
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
const people = [ | |
{ | |
name: "Joseph", | |
age: 32, | |
gender: "male", | |
}, | |
{ | |
name: "Anna", | |
age: 27, | |
gender: "female", |
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
async function run() { | |
var test = { | |
value: 0, | |
}; | |
const testss = await new Promise(accept => | |
setTimeout(() => ((test.value = 90), console.log(test.value), accept()), 0), | |
); | |
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
//enum is a reserved word in new ES6 reserved words list, that's the reason the method call ENUM_ | |
class Enum_ { | |
constructor(...list) { | |
const objList = list.reduce((acummulator, value) => { | |
acummulator[value] = Symbol(value); | |
return acummulator; | |
}, {}); | |
return Object.freeze(objList); | |
} |
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
/* WITHOUT STATE PATTERN EXAMPLE */ | |
class TVRemoteWithoutStatePattern { | |
constructor() { | |
this.channel = 1; | |
} | |
setChannel(channel) { | |
this.channel = channel; | |
} |
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
/* STATE PATTERN EXAMPLE */ | |
class TVRemoteChannel1State { | |
displayStatus() { | |
console.log("Hello now watch sports on channel 1"); | |
} | |
} | |
class TVRemoteChannel2State { | |
displayStatus() { |