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 symbol1 = Symbol('Awesome'); | |
symbol1.description; | |
// "Awesome" |
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
try { | |
throw new Error('Useless Error'); | |
} catch { | |
console.log('Ignoring the exception'); | |
} | |
// Ignoring the exception |
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 /* 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 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
class User { | |
name: string = 'Marcos'; | |
changePassword(newPassword: string) { } | |
} | |
const user = new User(); | |
for (const key in user) { | |
console.log(key); |
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 enumerable(newValue: boolean) { | |
return ( | |
target: any, | |
propertyKey: string, | |
propertyDescriptor: PropertyDescriptor, | |
) => { | |
propertyDescriptor.enumerable = newValue; | |
} | |
} |
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 enumerable(newValue: boolean) { | |
return ( | |
target: any, | |
propertyKey: string, | |
propertyDescriptor: PropertyDescriptor, | |
) => { | |
propertyDescriptor.enumerable = newValue; | |
} | |
} | |
class User { |
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 enumerable(newValue: boolean) { | |
return ( | |
target: any, | |
propertyKey: string, | |
propertyDescriptor: PropertyDescriptor, | |
) => { | |
propertyDescriptor.enumerable = newValue; | |
} | |
} | |
class User { |
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 showInfo() { | |
return ( | |
target: any, | |
propertyKey: string, | |
parameterIndex: number, | |
) => { | |
console.log('target', target); | |
console.log('property key', propertyKey); | |
console.log('parameter index', parameterIndex); | |
} |
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 firstWay = !! 'works'; | |
const secondWay = Boolean('works'); | |
const thirdWay = new Boolean('works'); | |
if (firstWay == true) { | |
console.log('First way really works!'); | |
} | |
if (secondWay == true) { | |
console.log('Second way really works!'); |
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 firstWay = !! 'secret'; | |
const secondWay = Boolean('secret'); | |
const thirdWay = new Boolean('secret'); | |
console.log(typeof firstWay); | |
console.log(typeof secondWay); | |
console.log(typeof thirdWay); | |
// boolean | |
// boolean |