JavaScript Check Value is Undefined

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

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.