Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

void

The void operator evaluates the given expression and returns 'undefined', voiding the normal return functionality that the expression may produce.

Syntaxvoid expr

Examples

Void the return statement of a function. function doIt(){ alert("function executed"); return "some data"; } var result = void doIt(); alert( result ); Used in writing immediately-invoked function expressions. void function(){ alert("immediately invoked function expression"); }(); The first code block below uses void to override the normal functionality of a link's href attribute and run script instead. The second code block below does a similar thing without using the javascript: pseudo protocol. <a href="javascript: void( alert('do something via script') )">My link</a> <a href="#" onclick="return false" onmousedown="alert('ran javascript instead');">My link</a>

JavaScript

Operators

deleteinstanceofnewthistypeofternaryvoid