3 ms·
Missing my favourite when you don't care about a return value, which I personally find less fussy to type and look at (good for confusing Java developers who do
by insin 1y ago
Missing my favourite when you don't care about a return value, which I personally find less fussy to type and look at (good for confusing Java developers who don't share the fullness of the stack, too):
void function() {
…
}()
Escpecially when I can't be bothered to stop and extract an async function out when there's a sudden need to wait in a non-async context, handy when in the middle of adding features to browser extensions for apps:
let $el = document.querySelector(…) // oops, not available yet
void async function() {
let $el = await waitForElement(…)
}()
Edit: documented on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void#immediately_invoked_function_expressions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...