Undefined

suggest change

A let or var declaration without an initializer has the value undefined after the declaration executes:

let a;

console.log(a); // logs: undefined

Reading an undeclared identifier normally throws a ReferenceError. The typeof operator is a special case: it returns "undefined" for an undeclared identifier, which makes it useful for guarded feature checks. It also returns "undefined" for a declared binding whose value is undefined:

let a;
console.log(typeof a === "undefined"); // logs: true
console.log(typeof variableDoesNotExist === "undefined"); // logs: true

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents