What is the point of void operator in JavaScript? -
i've seen people using void
operator in code. have seen in href
attributes: javascript:void(0)
doesn't seem better javascript:;
so, justification of using void
operator?
<snip>
this reason bookmarklets wrap code inside void() or anonymous function doesn't return stop browser trying display result of executing bookmarklet. example:
javascript:void(window.open("dom_spy.html"))
if directly use code returns (a new window instance in case), browser end displaying that:
javascript:window.open("dom_spy.html");
in firefox above display:
[object window]
</snip>
Comments
Post a Comment