Comparing to null with double-equals

Compare a variable to null using two equal signs to check if it is null or undefined at the same time.

if (value === null || value === undefined) {
  // `value` is `null` or `undefined`
}

if (value == null) {
  // `value` is `null` or `undefined`
}

There is more to learn

Get free previews of my upcoming course materials and other bonus content to help you work smarter. I share tips straight to your inbox once a week. You can read previous mails in the newsletter archive.

Cannot show form because cookie consent was not given.