Name
return — NN 2 IE J1 ECMA 1
Synopsis
Stops execution of the current function. A return
statement can be located anywhere within the function, including
inside control structures. You can optionally specify a value to be
returned to the calling statement. This return value can be any
JavaScript data type. If a return
statement that
returns a value is in a loop or other control structure, there must
be a return
statement for each branch of the
execution tree, including a default return
statement if execution should reach the main execution scope near or
at the end of the function.
Syntax
return [value
]
Example
function validateNumber(form) { var oneChar for (var i = 0; i < userEntry.length; i++) { oneChar = form.entry.value.charAt(i) if (oneChar < "0" || oneChar > "9") { return false } } return true }
Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.