Multiply
The multiply operator is *.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var result = 3 * 5;
document.writeln(result); //15
</script>
</head>
<body>
</body>
</html>
If either of the operands isn't a number, it is converted to a number using the Number() casting function. An empty string is treated as 0, and the Boolean value of true is treated as 1.
The multiply operator has the following behaviors:
OPERAND 1 | OPERAND 2 | RESULT |
---|---|---|
number | number | regular arithmetic multiplication, may have result of Number.NEGATIVE_INFINITY or Number.POSITIVE_INFINITY |
any value | NaN | NaN |
NaN | any value | NaN |
Number.POSITIVE_INFINITY | 0 | NaN |
Infinity | any finite number other than 0 | Number.NEGATIVE_INFINITY or Number.POSITIVE_INFINITY depending on the sign of the second operand |
Infinity | Infinity | Infinity |
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Operators:
- JavaScript Operators
- Increment/Decrement Operators
- Increment/Decrement Operators for String, Boolean, Floating-point and Object
- Unary Plus and Minus
- Bitwise Not operator
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Left Shift
- Signed Right Shift
- Unsigned Right Shift
- Logical NOT
- Logical AND
- Logical OR
- Multiply
- Divide
- Modulus
- Add
- Subtract
- Relational Operators
- Equal and Not Equal
- Identically Equal and Not Identically Equal
- Conditional Operator
- Assignment Operators
- Comma Operator