Skip to content
JS
JavaScript error

SyntaxError

The JavaScript exception "return not in function" occurs when a return statement is called outside of a function.

Reference entryJavaScriptFetched
SyntaxError: Illegal return statement (V8-based)
As listed by MDN Web Docs
SyntaxError: return not in function (Firefox)
As listed by MDN Web Docs
SyntaxError: Return statements are only valid inside functions. (Safari)
As listed by MDN Web Docs
Category
SyntaxError
Severity
error
Runtime
both
or press Cmd/Ctrl + Enter. The text is only sent to this site to match it.
Source: MDN Web Docs. Data fetched 2026-09-25T01:48:37.273Z.