Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 688 Bytes

2016-01-30-converting-truthy-falsy-values-to.md

File metadata and controls

22 lines (18 loc) · 688 Bytes

title: Converting truthy/falsy values to boolean tip-number: 30 tip-username: hakhag tip-username-profile: https://github.com/hakhag tip-tldr: Logical operators are a core part of JavaScript, here you can see a a way you always get a true or false no matter what was given to it.

  • /en/converting-truthy-falsy-values-to-boolean/

You can convert a truthy or falsy value to true boolean with the !! operator.

!!''; // false
!!0; // false
!!null; // false
!!undefined; // false
!!NaN; // false

!!'hello'; // true
!!1; // true
!!{}; // true
!![]; // true