Students Empire

Learn Something New
Home

Multiply Operator


The multiply operator is represented by an asterisk *.

				var result = 3 * 5;
				console.log(result);
				

If either of the operands isn't a number, it is converted to a number behind the scenes using the Number() casting function. This means that an empty string is treated as 0, and the Boolean value of true is treated as 1.

The multiply operator has the following unique behaviors when dealing with special values:

The multiply operator has the following unique behaviors when dealing with special values:

Operand Result
If the operands are numbers, regular arithmetic multiplication is performed, two positives or two negatives equal a positive.operands with different signs yield a negative.If the result cannot be represented by ECMAScript, either Infinity or -Infinity is returned.
either operand is NaN result is NaN
If Infinity is multiplied by 0 result is NaN
If Infinity is multiplied by any finite number other than 0 the result is either Infinity or -Infinity, depending on the sign of the second operand
If Infinity is multiplied by Infinity result is Infinity
If either operand isn't a number it is converted to a number behind the scenes using Number() and then the other rules are applied.