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/Operators/Multiplication

://developer.mozilla.org/favicon.ico" />

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

View in English Always switch to English

Multiplikation (*)

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since Juli 2015.

Der Multiplikationsoperator (*) ergibt das Produkt der Operanden.

Probieren Sie es aus

console.log(3 * 4);
// Expected output: 12

console.log(-3 * 4);
// Expected output: -12

console.log("3" * 2);
// Expected output: 6

console.log("foo" * 2);
// Expected output: NaN

Syntax

js
x * y

Beschreibung

Der *-Operator ist für zwei Typen von Operanden überladen: number und BigInt. Er zwingt zuerst beide Operanden zu numerischen Werten und überprüft die Typen von ihnen. Er führt eine BigInt-Multiplikation aus, wenn beide Operanden zu BigInts werden; andernfalls führt er eine number-Multiplikation durch. Ein TypeError wird ausgelöst, wenn ein Operand zu einem BigInt wird, der andere jedoch eine number bleibt.

Beispiele

Multiplikation mit Zahlen

js
2 * 2; // 4
-2 * 2; // -4

Infinity * 0; // NaN
Infinity * Infinity; // Infinity

Andere, nicht BigInt-Werte werden zu Zahlen coerciert:

js
"foo" * 2; // NaN
"2" * 2; // 4

Multiplikation mit BigInts

js
2n * 2n; // 4n
-2n * 2n; // -4n

Sie können keine BigInt- und number-Operanden in der Multiplikation mischen.

js
2n * 2; // TypeError: Cannot mix BigInt and other types, use explicit conversions
2 * 2n; // TypeError: Cannot mix BigInt and other types, use explicit conversions

Um eine Multiplikation mit einem BigInt und einem Nicht-BigInt durchzuführen, konvertieren Sie einen der Operanden:

js
2n * BigInt(2); // 4n
Number(2n) * 2; // 4

Spezifikationen

Specification
ECMAScript® 2026 Language Specification
# sec-multiplicative-operators

Browser-Kompatibilität

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