DEV Community

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

Posted on • Edited on

4

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay