Truthy, falsy

Introduction

Like most computer languages, JavaScript supports Boolean data types; values which can be set to true or false. In addition, everything in JavaScript has an inherent Boolean value, generally known as either truthy or falsy:

Falsy

The following values are always falsy:

false  
0 A Number with value zero, including 0.0.
NaN A special Number value meaning Not-a-Number.
'' or "" An empty string.
null  
undefined Any undefined value, including special value undefined.

Truthy

Everything else is truthy, for example:

true  
Other Number values Any non-0, non-NaN Number, including Infinity - a special value, like NaN.
A non-empty string Any non-empty string, including 'false', '0' etc.
An Object Any Object, Array etc objects, empty or not.
A Function Any function.
etc  
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.