JavaScript void Operator
The void operator evaluates an expression and then returns undefined.
Description
The void operator evaluates the given expression and returns undefined. It used to appear in href="javascript:void(0)" links, a pattern that should be replaced with real buttons. Today it's mainly used to deliberately ignore a promise in an arrow function, onClick={() => void save()}.
The operand is still evaluated, so any side effects happen; only the result is thrown away. void 0 is a guaranteed way to get undefined, which minifiers use because it's shorter than the word and, in very old environments, undefined could be reassigned.
It's also seen in immediately invoked function expressions, void function () { ... }(), to make the parser treat the function as an expression. In modern code with modules and block scope, those uses are rare, and it's mostly a curiosity you'll recognize in older code or minified output.
Properties
- Operator
void- Category
- Unary
- Precedence
- 14 (1 is lowest, 18 is highest)
- Associativity
- right-to-left
Syntax
void expressionExample
Browser Support
The following information will show you the current browser support for the void operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





