• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Operators > Types of Operators

5.2. Types of Operators

5.2.1. Arithmetic Operators

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (–), multiplication (*), and division (/). See Table 5.2.

Table 5.2. Arithmetic operators.
Operator/OperandsFunction
x + yAddition
x – ySubtraction
x * yMultiplication
x / yDivision[a]
x % yModulus


[a] The / operator returns a floating-point division in JavaScript, not a truncated division as it does in languages such as C or Java. For example, 1/2 returns 0.5 in JavaScript and 1/2 returns 0 in Java.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint