
- 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 JavaScript undefined and void(0)?
JavaScript undefined
It means a variable declared, but no value has been assigned a value.
For example,
var demo; alert(demo); //shows undefined alert(type of demo); //shows undefined
Here’s another example showing the usage of undefined to check whether a variable exists or not:
Example
<html> <body> <script> var age = 10; if( typeof age !== 'undefined' ) { document.write("True"); } else{ document.write("False"); } </script> </body> </html>
Output
True
JavaScript void(0)
The void is an important keyword in JavaScript, which can be used as a unary operator that appears before its single operand, which may be of any type. This operator specifies an expression to be evaluated without returning a value.
The syntax of the void can be either of the following two −
<head> <script> <!-- void func() javascript:void func() or: void(func()) javascript:void(func()) //--> </script> </head>
- Related Articles
- What is the difference between null and undefined in JavaScript?
- What is the difference between undefined and not defined in JavaScript?
- What is the meaning of JavaScript void 0?
- What is the difference between void, eval, and the Function constructor in JavaScript?
- What is the difference between public, static and void keywords in C#?
- What is Undefined X1 in JavaScript
- What is the difference between jQuery and JavaScript?
- What is the difference between Java and JavaScript?
- What is the difference between JavaScript and ECMAScript?
- What is the difference between JavaScript and C++?
- What is the difference between == and === in JavaScript?
- What is the difference between comments /*...*/ and /**...*/ in JavaScript?
- What is "undefined x 1" in JavaScript?
- How to fix problems related to the JavaScript Void 0 Error?
- Difference between void main and int main in C/C++

Advertisements