Skip to content

Instantly share code, notes, and snippets.

View omarkdev's full-sized avatar

Marcos Felipe omarkdev

View GitHub Profile
const symbol1 = Symbol('Awesome');
symbol1.description;
// "Awesome"
try {
throw new Error('Useless Error');
} catch {
console.log('Ignoring the exception');
}
// Ignoring the exception
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
// }"
class User {
name: string = 'Marcos';
changePassword(newPassword: string) { }
}
const user = new User();
for (const key in user) {
console.log(key);
function enumerable(newValue: boolean) {
return (
target: any,
propertyKey: string,
propertyDescriptor: PropertyDescriptor,
) => {
propertyDescriptor.enumerable = newValue;
}
}
function enumerable(newValue: boolean) {
return (
target: any,
propertyKey: string,
propertyDescriptor: PropertyDescriptor,
) => {
propertyDescriptor.enumerable = newValue;
}
}
class User {
function enumerable(newValue: boolean) {
return (
target: any,
propertyKey: string,
propertyDescriptor: PropertyDescriptor,
) => {
propertyDescriptor.enumerable = newValue;
}
}
class User {
function showInfo() {
return (
target: any,
propertyKey: string,
parameterIndex: number,
) => {
console.log('target', target);
console.log('property key', propertyKey);
console.log('parameter index', parameterIndex);
}
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!');
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