What Is Difference Between Undefined and Object? - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
What Is Difference Between Undefined and Object?

What Is Difference Between Undefined and Object?

Many a times we often get confused on whats the difference between UNDEFINED and NULL.
undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value.
Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.
Unassigned variables are initialized by JavaScript with a default value of undefined. JavaScript never sets a value to null. That must be done programmatically.

Undefined – The undefined means some variable is declared but the value of variable is not defined yet.

Object - Object means some variable is declared but the value of variable is not defined that is either function, object OR array.

You can easily be understanding in the below example in detail –

let emp//The declaration of emp is hoisted but the value of emp is  undefined.
console.log(emp); //The output is undefined

console.log(typeof(null));      // object
console.log(typeof(undefined)); // undefined

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.