
JavaScriptWeb DevelopmentTutorialProgramming Concepts
Undefined vs Not defined
1 min read
- In first phase (memory allocation) JS assigns each variable a placeholder called undefined.
- undefined is when memory is allocated for the variable, but no value is assigned yet.
Example 1
console.log(x); // undefined
var x = 25;
console.log(x); // 25
console.log(a); // Uncaught ReferenceError: a is not defined- If an object or variable is not even declared or found in memory allocation phase, and tried to access it then it is Not defined. Not Defined !== Undefined
- When variable is declared but not assigned with any value , then its current value is undefined. But when the variable itself is not declared but called in code, then it is not defined.
- JS is a loosely typed / weakly typed language. It doesn't attach variables to any datatype. We can say
var a = 5, and then change the value to Booleana = trueor stringa = 'hello'later on. - Never assign undefined to a variable manually. Let it happen on it's own accord.

Share this article
Enjoyed it?
Browse More Blogs
Article•7 min read
Building 99.7% Reliable n8n Workflows: The Validation Guide
Learn how to fix the n8n empty object bug and achieve 99.7% reliability using a 3-layer validation architecture. Stop sending blank emails forever.
Read Article
Article•7 min read
Next.js Lighthouse Optimization: 42 to 97 Case Study
See how Aman Suryavanshi optimized Next.js performance from 42 to 97 Lighthouse score, driving ₹3L+ revenue. Learn image, code, and font optimization.
Read Article
Article•7 min read
How I Built an Organic Lead Gen Machine: A ₹3 Lakh Case Study
See how Aman Suryavanshi replaced ₹50k/month ad spend with a Next.js 14 and n8n automation system, generating ₹3L+ in organic revenue for a DGCA school.
Read Article
Let's Create Something Amazing Together!
Whether you have a project in mind or just want to connect, I'm always excited to collaborate and bring ideas to life.
Continue the Journey
Thanks for taking the time to explore my work! Let's connect and create something amazing together.