Undefined or not defined?

Table of Content

What is Undefined in JavaScript?
What is ‘defined` in JavaScript ?
Difference between the both.

Undefined

Undefined is simply a Placeholder that is initialise to every variable at the time of memory execution …


This content originally appeared on DEV Community and was authored by Utkarsh Yadav

Table of Content

  • What is Undefined in JavaScript?
  • What is 'defined` in JavaScript ?
  • Difference between the both.

Undefined

Undefined is simply a Placeholder that is initialise to every variable at the time of memory execution in Global Execution Context.

Example:


console.log(a); // undefined
var a = 7; // Assign value 7 to a
console.log(a); // Log --> 7 on Screen

Not Defined

This is like an error, occurs when the code is trying to access the variable that is never been there in memory.

is
var b = 7; // Assign value 7 to b
console.log(a); // not defined

Difference Between Undefined and Not Defined

In JavaScript, they both are related to memory space and there is a very simple difference between them. If the variable name which is being accessed doesn’t exist in memory space then it would be not defined, and if exists in memory space but hasn’t been assigned any value till now, then it would be undefined.

So, Hope you got to know the simple difference between the two Jargons.

Don't stop learning, Keep exploring and learning.


This content originally appeared on DEV Community and was authored by Utkarsh Yadav


Print Share Comment Cite Upload Translate Updates
APA

Utkarsh Yadav | Sciencx (2021-10-27T10:28:05+00:00) Undefined or not defined?. Retrieved from https://www.scien.cx/2021/10/27/undefined-or-not-defined/

MLA
" » Undefined or not defined?." Utkarsh Yadav | Sciencx - Wednesday October 27, 2021, https://www.scien.cx/2021/10/27/undefined-or-not-defined/
HARVARD
Utkarsh Yadav | Sciencx Wednesday October 27, 2021 » Undefined or not defined?., viewed ,<https://www.scien.cx/2021/10/27/undefined-or-not-defined/>
VANCOUVER
Utkarsh Yadav | Sciencx - » Undefined or not defined?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/27/undefined-or-not-defined/
CHICAGO
" » Undefined or not defined?." Utkarsh Yadav | Sciencx - Accessed . https://www.scien.cx/2021/10/27/undefined-or-not-defined/
IEEE
" » Undefined or not defined?." Utkarsh Yadav | Sciencx [Online]. Available: https://www.scien.cx/2021/10/27/undefined-or-not-defined/. [Accessed: ]
rf:citation
» Undefined or not defined? | Utkarsh Yadav | Sciencx | https://www.scien.cx/2021/10/27/undefined-or-not-defined/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.