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 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 |
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 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)); |
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 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] |
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(firstWay === true); | |
| console.log(secondWay === true); | |
| console.log(thirdWay === true); | |
| // true | |
| // true |
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 |
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
| 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
| 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 enumerable(newValue: boolean) { | |
| return ( | |
| target: any, | |
| propertyKey: string, | |
| propertyDescriptor: PropertyDescriptor, | |
| ) => { | |
| propertyDescriptor.enumerable = newValue; | |
| } | |
| } |