3 ms·
For those of you that write in JS (and not TypeScript), do you use "void 0" instead of "undefined"? I use undefined and would hate to switch to void 0, since it
by ohitsdom 10y ago
For those of you that write in JS (and not TypeScript), do you use "void 0" instead of "undefined"? I use undefined and would hate to switch to void 0, since it's less clear and unnecessary thanks to tools like JSHint.
- v413 10y agoPrior to ES5 undefined was overwritable that is why void 0 guaranteed to produce undefined. With ES5 and later using undefined directly is safe.
- pygy_ 10y ago`undefined` is a variable that can (could? It may have changed with strict mode or ES6) be set globally to arbitrary values. You can use `undefined` safely with an IIFE wrapper: (function(undefined) { // you're safe here }());