What is "undefined"?
- In JavaScript, "undefined" is a primitive value automatically assigned to variables that have been declared but have not been initialized with a value. It also represents the value returned by functions that do not explicitly return anything. Essentially, it denotes the absence of a meaningful value.
Example
let x;
console.log(x); // Output: undefined
function doSomething() {
// Kuch bhi return nahi kiya gaya
}
console.log(doSomething()); // Output: undefined
Not defined
- In JavaScript Not Defined is a ReferenceError that occurs when you try to use a variable, function, or object property that has not been declared or created in your code. This error is often caused by typographical mistakes or using the wrong variable name.
console.log(a);
var a = 5;
console.log(a);
console.log(b); // // ReferenceError: b is not defined
What is null in JavaScript?
- In JavaScript, null is a special value that represents an empty or unknown value. It is often used to indicate that a variable or object property has no value or is explicitly empty. Unlike undefined, null is a deliberate assignment to a variable to indicate that it has no value.
Link
Join Discord :- https://github.com/Coder-Studies
Follow Us of Github :- https://github.com/Coder-Studies
Top comments (3)
Informative !!!
Join Our Discord Community . To Stay Updated discord.gg/b44tgZGz
Thanks