What is the point of void operator in JavaScript?

Explanation of its use in links:

This is the reason that bookmarklets
often wrap the code inside void() or
an anonymous function that doesn’t
return anything to stop the browser
from trying to display the result of
executing the bookmarklet. For
example:

javascript:void(window.open("dom_spy.html"))

If you directly use code that returns
something (a new window instance in
this case), the browser will end up
displaying that:

javascript:window.open("dom_spy.html");

In Firefox the above will display:

[object Window]

Leave a Comment