- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements