loading...
Cover image for Falsy Values are N0 FUN!

Falsy Values are N0 FUN!

denmch profile image Den McHenry ・1 min read

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 "" (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.

Posted on by:

denmch profile

Den McHenry

@denmch

I used to teach Latin, but now I make websites. Still a union worker. Ersatz cartoonist. All around great dad. You can dig my grave in Mammoth Cave.

Discussion

pic
Editor guide