Working with null and undefined in JavaScript

b123400
b123400
Jul 28, 2017 · 3 min read

JavaScript is a nice language and a good starting point for beginners to learn programming. So here is a tutorial of a simple task: How do you work with null and undefined?

A simple Google search gives you answer as simple as this:

if (x === undefined || x === null) {
// these statements execute
}

However, this is very 2000. In the modern JS world, we use smaller packages to compose a larger program. Here are some packages for you to do the complicated job.

Check for either null or undefined

Check if the value is undefined

Check if the value is null

The other way round

Generic type checking packages

If branching

Converting undefined into null

Convert to a default value

Filtering

b123400

Written by

b123400

Digital nomad

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade