Michael Landis
1 min readMar 10, 2020

--

There aren’t many places where I need to do this conversion, since Javascript does automatic coercion. 0, null, undefined, and ‘’ all act as false values in tests, and a simple negation gives me truthy values.

One place where Boolean() is especially useful is Array.prototype.filter(Boolean()), which strips null and undefined references from an array of objects.

--

--

Michael Landis
Michael Landis

Written by Michael Landis

Front-end web developer, React enthusiast, vagabond.

Responses (1)