Skip to main content

Javascript-basics:
Undefined vs Undeclared

image for Undefined vs Undeclared

Undefined vs Undeclared

Undefined is a value that a declared variable or function can have when it has not been assigned a value or has no explicit return value.

Undeclared refers to using a variable that has not been declared using var, let, or const, and it can lead to different behaviors depending on whether you are in strict mode or not. In strict mode, it results in a reference error, and in non-strict mode, it creates a global variable.