Back to Browse

JavaScript tips — The void operator

1.7K views
Jan 23, 2023
4:41

The void operator in JavaScript is a unary operator that evaluates an expression but then discards the result to instead return undefined This is a specialized operator that you may not use everyday but can be helpful in specific situations. One common use is with arrow functions to make sure the arrow function returns undefined instead of leaking a return value You'll also see 'void(0)' often used in minified code to get 'undefined' with fewer characters https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void #javascript

Download

1 formats

Video Formats

360pmp45.6 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

JavaScript tips — The void operator | NatokHD