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


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

URL: http://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Errors/Duplicate_parameter

="/static/client/index.455dc24ca3b6b460.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: doppeltes formales Argument x

Der JavaScript-Ausnahmefehler "doppeltes formales Argument x" oder "doppelte Argumentnamen sind in diesem Kontext nicht erlaubt" tritt auf, wenn eine Funktion zwei oder mehr Parameter-Bindings mit demselben Namen erstellt und die Funktion keine nicht-strikte Funktion mit nur einfachen Parametern ist.

Meldung

SyntaxError: Duplicate parameter name not allowed in this context (V8-based)
SyntaxError: duplicate formal argument x (Firefox)
SyntaxError: duplicate argument names not allowed in this context (Firefox)
SyntaxError: Cannot declare a parameter named 'x' in strict mode as it has already been declared. (Safari)
SyntaxError: Duplicate parameter 'x' not allowed in function with default parameter values. (Safari)
SyntaxError: Duplicate parameter 'x' not allowed in function with a rest parameter. (Safari)
SyntaxError: Duplicate parameter 'x' not allowed in function with destructuring parameters. (Safari)

Fehlertyp

SyntaxError

Was ist schiefgegangen?

Zwei formale Parameter mit demselben Namen zu haben, ist wahrscheinlich ein Fehler – das zweite Auftreten würde dazu führen, dass das erste Auftreten über den Parameternamen nicht zugänglich ist. In älterem JavaScript war dies erlaubt. Um bestehenden Code nicht zu brechen, ist dies nur dann ein Fehler, wenn der Code garantiert nicht veraltet ist – entweder weil er im strikten Modus ist oder weil er moderne Parametersyntax verwendet (Rest, Standard- oder destrukturierte Parameter).

Beispiele

Ungültige Fälle

js
"use strict";

function add(x, x) {
  // How can you access both "x" parameters?
  // SyntaxError: duplicate formal argument x
}
js
function doSomething(name, { name }) {
  // How can you access both "name" parameters?
  // SyntaxError: duplicate argument names not allowed in this context
}

Gültige Fälle

js
function doSomething(operationName, { name: userName }) {
  // You can access both "operationName" and "userName" parameters.
}

function doSomething(name, user) {
  // You can access both "name" and "user.name" parameters.
}

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