An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
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 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 doesnt exist in memory space then it would be not defined, and if exists in memory space but hasnt 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.
Original Link: https://dev.to/utkarshwhocodes/undefined-or-not-defined-f5m
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To