Nice Javascript
🎯 Min-Max shorthand
1 | // If argument is less than min value, set min value. |
🎯 Curly brackets in console.log
1 | // Curly brackets in console.log turns the value into object with key |
🎯 Bang Bang
1 | !!0; // this returns false 😵 |
🎯 Typescript - Type
🎯 Immediately Invoked Function Expression(IIFE)
1 | // ver1: Ah I can find it everywhere :D |
🎯 Simple Heavy work and Sleep method
1 | // Promise method |
1 | // heavy task method |
1 | // sleep method |
🎯 Display JSON data
1 | <pre>{JSON.stringify(data, null, 2)}</pre> |
🎯 Add to array with if condition
1 | const flag = false; |
🎯 Short hand of switch
1 | const one = () => console.log('ONE'); |
🎯 Build full name from data object
1 | const data = { |
🎯 ?? vs ||
??
checks only null
or undefined
.||
checks false
(boolean), ''
(empty string), 0
(number), null
and undefined
.