Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

return

The return statement is used to return a value from a function. It terminates the function from further executing code, and optionally returns a value to the caller.

Syntaxreturn value;
function addNums(n1, n2) { return n1 + n2; } var sum = addNums(2, 3); alert( sum );

Here is an example using 'return false' to disable the normal click event functionality of a link.

<script> function jsFunction(){ alert("This JavaScript function is now handling the mousedown event for that link."); } </script> <a onclick="return false" href="#" onmousedown="jsFunction()">Click Me</a>

JavaScript

Statements

breakconstcontinuedo whileforfor inif elselabelreturnswitchtry catchvarwhilewith