| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Operators/Multiplication | [Back] [Original] |
Get to know MDN better
Esta pgina ha sido traducida del ingls por la comunidad. Aprende ms y nete a la comunidad de MDN Web Docs.
This feature is well established and works across many devices and browser versions. Its been available across browsers since julio de 2015.
El operador de multiplicacin (*) produce el producto de dos operandos.
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
x * y
El operador * acepta dos tipos de operandos: nmero y BigInt. Primero intenta transformar ambos operandos a valores numricos y prueba sus tipos. Realiza una multiplicacin BigInt si ambos operandos se convierten en BigInts; de lo contrario, realiza la multiplicacin de nmeros. Se genera un TypeError si un operando es convertido a BigInt pero el otro se convierte en un nmero.
2 * 2; // 4
-2 * 2; // -4
Infinity * 0; // NaN
Infinity * Infinity; // Infinity
"foo" * 2; // NaN
"2" * 2; // 4
2n * 2n; // 4n
-2n * 2n; // -4n
2n * 2; // TypeError: Cannot mix BigInt and other types, use explicit conversions
// Para multiplicar un BigInt por un elemento que no es un BigInt, convierta cualquiera de los dos operandos
2n * BigInt(2); // 4n
Number(2n) * 2; // 4
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-multiplicative-operators |
+)-)/)%)**)++)--)-)+)This page was last modified on 20 jun 2025 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |