
- 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
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.
- Related Articles
- How to deal with error “var(x) : Calling var(x) on a factor x is defunct.” in R?
- Difference between var and let in JavaScript
- Why doesn't JavaScript support multithreading?
- Usage of var() CSS function
- Why doesn't JavaScript have a goto statement?
- Why does C++ require a cast for malloc() but C doesn't?
- What is the purpose of the var keyword in JavaScript?
- Metal react with water but why non-metal doesn't react with water?
- What does the operator || do in a var statement in JavaScript?
- Difference between Var and Dynamics in C#
- Difference between var and dynamic in C#
- Python3 - Why loop doesn't work?
- What does the keyword var do in C#?
- Why milk doesn't contain Vitamin C?
- What is the difference between: var functionName = function() {} and function functionName() {} in Javascript

Advertisements