Javascript - Operator Multiply Operator

Introduction

The multiply operator is * and is used to multiply two numbers.

var result = 4 * 5; 

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

Operanad 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.

Related Topic