How to convert truthy/falsy to boolean (true/false)
const myVar = null; const mySecondVar = 1; console.log( Boolean(myVar) ) // false console.log( !!myVar ) // false console.log( Boolean(mySecondVar) ) // true
console.log( !!mySecondVar ) // true
If you know other methods please let me know, thanks.
I will post A JS tip per day! Please follow me on LinkedIn / Twitter / Facebook / Codesandbox / Codepen.