Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ ⟩ ⟩ void
(operator)
evaluates its operand, then discards the value and returns undefined.
// ⭐ syntax: void <expr> const count = () => void counter++; // ⭐ void: discard return value
(replit)
let counter = 0; // ⭐ void: discard return value const count = () => void counter++; const count2 = () => { counter++ }; // same as above count(), // undefined counter, // 1 count2(), // undefined counter++, // 2
JavaScript: The Definitive Guide ⟩ 4.13.6 The void Operator
void expr or void(expr) evaluates the given expr and then returns .
void
expr
void(
)
some transpilers turn undefined into void 0.
undefined