Truthy and Falsy

Though Liquid is platform-independent, there’re certain differences with the Ruby version, one of which is the truthy value.

The Truth Table

According to Shopify document everything other than false and nil is truthy. But in JavaScript we have a totally different type system, we have types like undefined and we don’t differentiate integer and float, thus things are slightly different:

value truthy falsy
true ✔️
false ✔️
null ✔️
undefined ✔️
string ✔️
empty string ✔️
0 ✔️
integer ✔️
float ✔️
array ✔️
empty array ✔️

Use JavaScript Truthy

Note that liquidjs use Shopify’s truthiness by default. But it can be toggled to used standard JavaScript truthiness by setting the jsTruthy option to true.

value truthy falsy
true ✔️
false ✔️
null ✔️
undefined ✔️
string ✔️
empty string ✔️
0 ✔️
integer ✔️
float ✔️
array ✔️
empty array ✔️