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?

explanation of use in links:

<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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -