JavaScript Check Value is Undefined

Published: Feb 03, 2023

Let's use the strict equality operator to check if the val is equal to undefined or not.

The strict equality (===) operator checks whether its two operands are equal, returning a Boolean result.

let variable1 = undefined;
let variable2 = '';

const isValUndefined = val => val === undefined;

let result1 = isValUndefined(variable1);
let result2 = isValUndefined(variable2);

console.log(result1); // true
console.log(result2); // false