O'Reilly logo

JavaScript™ 1.5 by Example by Kathie Kingsley-Hughes, Adrian Kingsley-Hughes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing Operators

Expressions and conditions combine data using operators. Operators must work on something to be able to operate. They can work on one piece of data, which makes them unary operators. They can work on two pieces of data, which makes them binary operators, or they can work on three pieces of data, which makes them ternary operators.

Let's look at some of the more common operators.

Arithmetic Operators

These operators are the familiar mathematical ones. They are

  • Plus (+)

    1 + 3 = 4
    
  • Minus (-)

    2 - 1 = 1
    
  • Division (/)

    4 / 2 = 2
    
  • Multiplication (*)

    2 * 2 = 4
    
  • Modulus (%)

    9 % 5 = 4
    

NOTE

All these operators are binary.

The only arithmetic operator that might need further explanation is the modulus operator. This operator, also called ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required