
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the difference between null and undefined in JavaScript?
In JavaScript, undefined is a type, whereas null an object.
undefined
It means a variable declared, but no value has been assigned a value.
For example,
var demo; alert(demo); //shows undefined alert(typeof demo); //shows undefined
null
Whereas, null in JavaScript is an assignment value. You can assign it to a variable.
For example,
var demo = null; alert(demo); //shows null alert(typeof demo); //shows object
- Related Articles
- What is the difference between JavaScript undefined and void(0)?
- What is the difference between undefined and not defined in JavaScript?
- In MySQL what is the difference between != NULL and IS NOT NULL?
- Difference Between MySql NULL and IS NOT NULL?
- Replace a value if null or undefined in JavaScript?
- How to check empty/undefined/null strings in JavaScript?
- How to get the first non-null/undefined argument in JavaScript?
- What is Undefined X1 in JavaScript
- What is the difference between MySQL ISNULL() function and IS NULL operator?
- What is the difference between == and === in JavaScript?
- What is "undefined x 1" in JavaScript?
- What is the difference between comments /*...*/ and /**...*/ in JavaScript?
- What is the relation between 'null' and '0' in JavaScript?
- What is the difference between jQuery and JavaScript?
- What is the difference between Java and JavaScript?

Advertisements