This file contains 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
class User { | |
name: string = 'Marcos'; | |
changePassword(newPassword: string) { } | |
} | |
const user = new User(); | |
for (const key in user) { | |
console.log(key); |
This file contains 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 /* Sum two numbers */ sum(a, b) { | |
return a + b; // Sum a + b | |
} | |
sum.toString(); | |
// "function /* Sum two numbers */ sum(a, b) { | |
// return a + b; // Sum a + b | |
// }" |
This file contains 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
try { | |
throw new Error('Useless Error'); | |
} catch { | |
console.log('Ignoring the exception'); | |
} | |
// Ignoring the exception |
This file contains 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 symbol1 = Symbol('Awesome'); | |
symbol1.description; | |
// "Awesome" |
This file contains 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 symbol1 = Symbol('Awesome'); | |
symbol1.toString(); | |
// "Symbol(Awesome)" |
This file contains 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 message = ' Hello world! '; | |
message.trimEnd(); | |
// " Hello world!" | |
message.trimStart(); | |
// "Hello world! " |
This file contains 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 entries = [ ['name', 'Marcos'], ['site', 'omark.dev'], ['twitter', '@omarkdev'] ]; | |
Object.fromEntries(entries); | |
// {name: "Marcos", site: "omark.dev", twitter: "@omarkdev"} |
This file contains 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 arr1 = [1, 2, 3, 4]; | |
const arr1FlattedMultipliedByTwo = arr1.flatMap(v => [ v * 2 ]); | |
// arr1FlattedMultipliedByTwo |
This file contains 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 arr1 = ['a', 'b', , , , ['c', , 1, null, undefined, '', 0]]; | |
const arr1Flatted = arr1.flat(); | |
// ["a", "b", "c", 1, null, undefined, "", 0] |
This file contains 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 arr1 = ['a', ['b', ['c']], 1, [2, [3, [4, [5]]]]]; | |
const arr1Flatted1 = arr1.flat(); | |
// ["a", "b", Array(1), 1, 2, Array(2)] | |
const arr1Flatted2 = arr1.flat(2); | |
// ["a", "b", "c", 1, 2, 3, Array(2)] | |
const arr1FlattedInfinity = arr1.flat(Infinity); | |
// ["a", "b", "c", 1, 2, 3, 4, 5] |