DEV Community

Cover image for Falsy Values are N0 FUN!
Den McHenry
Den McHenry

Posted on • Updated on

Falsy Values are N0 FUN!

When I was a Latin teacher, I used to love coming up with mnemonic devices to help students remember novel or difficult things, like the order of the Roman kings, or the endings of verbs. But as I think about it, it's a technique I use for myself all the time.

Example: I just came up with a simple mnemonic device to remember the falsy values in JavaScript.

falsy values == N0 FUN

N0:

  • NaN
  • 0 or -0 or "" (empty string, i.e., String.length === 0)

FUN:

  • false
  • undefined
  • null

Now, this doesn't mean that YOU can't enjoy falsy values. You may think they're just as fun, fun, fun, fun, FUN! as kazoo, but just as Every Good Boy"" doesn't necessarily Do Fine, remember: falsy values are N0 FUN.

Top comments (0)