Boolean Data Type - Python, Ruby, and JavaScript

Python, Ruby, and JavaScript

In Python, a numeric value of zero (integer or fractional), the null value (None), the empty string, and empty containers (i.e. lists, sets, etc.) are considered Boolean false; all other values are considered Boolean true by default.

In Ruby, on the other hand, only nil (Ruby's null value) and a special false object are "false", everything else (including the integer 0 and empty arrays) is "true".

In JavaScript, the empty string (""), null, undefined, NaN, +0, −0 and false are sometimes called "falsy", and their complement, "truthy", to distinguish between strictly type-checked and coerced Booleans. Languages such as PHP also use this approach.

Read more about this topic:  Boolean Data Type