Basic Operators
Mathematic operations to numbers can be performed using some basic operators like:
Addition:
c = a + b
Subtraction:
c = a - b
Multiplication:
c = a * b
Division:
c = a / b
The JavaScript interpreter works from left to right. One can use parentheses just like in math to separate and group expressions: c = (a / b) + d
JavaScript uses the +
operator for both addition and concatenation. Numbers are added whereas strings are concatenated.
NaN
is a reserved word indicating that a number is not a legal number, this arises when we perform arithmetic with a non-numeric string will result in NaN
(Not a Number).
The parseInt
method parses a value as a string and returns the first integer.
In JavaScript, if we calculate a number outside the largest possible number it returns Infinity
.
Last updated
Was this helpful?