- Trending Categories
- 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
Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
The web browser throws an error for “var null” because it is a reserved identifier.
You cannot use the following literals as identifiers in ECMAScript −
null frue false
undefined
A property with no definition. It is not known and not a reserved identifier. Its type is undefined.
null
It is known and a reserved identifier. But “null” isn’t the same as “false”. When you will declare a variable and set it to null, then null will get printed.
Advertisements