Skip to content

Instantly share code, notes, and snippets.

View omarkdev's full-sized avatar

Marcos Felipe omarkdev

View GitHub Profile
const result = new Boolean('awesome');
result.origin = 'https://omark.dev';
console.log(result);
console.log(result == true);
console.log(result === true);
// { [Boolean: true] origin: 'https://omark.dev' }
// true
const falseExample = false;
const undefinedExample = undefined;
const nullExample = null;
const NaNExample = NaN;
const zeroExample = 0;
const stringExample = "";
console.log(!! falseExample, Boolean(falseExample), new Boolean(falseExample));
console.log(!! undefinedExample, Boolean(undefinedExample), new Boolean(undefinedExample));
console.log(!! nullExample, Boolean(nullExample), new Boolean(nullExample));
const numberExample = -1;
const stringExample = 'Awesome';
console.log(!! numberExample, !! stringExample);
console.log(Boolean(numberExample), Boolean(stringExample));
console.log(new Boolean(numberExample), new Boolean(stringExample));
// true true
// true true
// [Boolean: true] [Boolean: true]
const firstWay = !! 'secret';
const secondWay = Boolean('secret');
const thirdWay = new Boolean('secret');
console.log(firstWay === true);
console.log(secondWay === true);
console.log(thirdWay === true);
// true
// true
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
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!');
function showInfo() {
return (
target: any,
propertyKey: string,
parameterIndex: number,
) => {
console.log('target', target);
console.log('property key', propertyKey);
console.log('parameter index', parameterIndex);
}
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 enumerable(newValue: boolean) {
return (
target: any,
propertyKey: string,
propertyDescriptor: PropertyDescriptor,
) => {
propertyDescriptor.enumerable = newValue;
}
}