Hosting Solutions
mobile_logo Table of Contents


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>



breakconstcontinuedo whileforfor inif elselabelreturnswitchtry catchvarwhilewith