pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Errors/Bad_return

"/static/client/1111.53dba753dc3eb961.js" type="module">

Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten. Erfahre mehr über dieses Experiment.

View in English Always switch to English

SyntaxError: return not in function

Das JavaScript-Exception "return not in function" tritt auf, wenn eine return-Anweisung außerhalb einer Funktion aufgerufen wird.

Nachricht

SyntaxError: Illegal return statement (V8-based)
SyntaxError: return not in function (Firefox)
SyntaxError: Return statements are only valid inside functions. (Safari)

Fehlertyp

SyntaxError.

Was ist schiefgelaufen?

Eine return-Anweisung wird außerhalb einer Funktion aufgerufen. Möglicherweise fehlen irgendwo geschweifte Klammern? Die return-Anweisung muss in einer Funktion stehen, da sie die Funktionsausführung beendet und einen Wert an den Funktionsaufrufer zurückgibt.

Beispiele

Fehlende geschweifte Klammern

js
function cheer(score) {
  if (score === 147)
    return "Maximum!";
  }
  if (score > 100) {
    return "Century!";
  }
}

// SyntaxError: return not in function

Die geschweiften Klammern sehen auf den ersten Blick korrekt aus, aber in diesem Codeausschnitt fehlt eine { nach der ersten if-Anweisung. Korrekt wäre:

js
function cheer(score) {
  if (score === 147) {
    return "Maximum!";
  }
  if (score > 100) {
    return "Century!";
  }
}

Siehe auch

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy