Peter Seliger
Jan 20, 2024

--

void(0) ... written like that, is first and foremost crap. void is an operator that's sole task is to evaluate any following expression and always (means regardless of the expression) to return the undefined value. Thus, if encountering something like void(0) it's most probably copy/pasted without the slightest attempt of critical thinking. Since void is an operator and not a function, writing it like void 0 comes closer to its true nature. Hence, "javascript:void(0)" translates directly into "javascript:undefined". But 25 or more years ago one did not write it like that because the undefined values could be overwritten like a global variable. But void 0 always assured an unspoofed undefined value, only that people back then didn't bother about documentation/specification and whether void being an operator. And this, botchery and ignorance, are the true dark forces behind this code snippets longevity.

--

--

Responses (1)