I googled your code snippet and it looks like its typically embedded in a link with "javascript:" in front of it. To quote the Mozilla reference for the void operator:
JavaScript URIs
When a browser follows a javascript: URI, it evaluates the code in the URI and then replaces the contents of the page with the returned value, unless the returned value is undefined. The void operator can be used to return undefined. For example:
<a href="javascript:void(0);">Click here to do nothing</a>
<a href="javascript:void(document.body.style.backgroundColor='green');">Click here for green background</a>
Note, however, that javascript: URIs are now often discouraged over other alternatives, such as events.
source: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/void
So it keeps the contents of the page from being overwritten when the code is executed inside of a link.
In this case, if the code is executed without the javascript: URI, the void operator should not make any difference. The void operator simply evaluates its input expression and returns undefined.