Skip to content

Latest commit

 

History

History
12 lines (6 loc) · 543 Bytes

5. what is the difference between undeclared and undefinded in js.md

File metadata and controls

12 lines (6 loc) · 543 Bytes

what is the difference between undeclared and undefinded in js

Undefined: It occurs when a variable has been declared but has not been assigned with any value. Undefined is not a keyword.

Undeclared: It occurs when we try to access any variable that is not initialized or declared earlier using var or const keyword. If we use ‘typeof’ operator to get the value of an undeclared variable, we will face the runtime error with return value as “undefined”.

Note : The scope of the undeclared variables is always global.