JavaScript

Tuesday April 8, 2025
updated: April 10, 2002

 
Home
Getting Started
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Resources
Credits

 

 


Lesson 4: OPERATORS

ARITHMETIC

Arithmetic Operators are symbols that are used with variables to allow us to perform certain functions, such as adding, subtracting and etc. The table on the left lists the operators available in JavaScript and describes what it does (assuming the two variables x and y that have been declared and initialized with a value).

operator what it does
x + y (numeric) Adds x and y
x + y (string)
Concatenates x and y
x - y Subtracts x from y
x * y Multiplies x b y
x / y Divides x by y
x % y
Remainder of x / y , modulus
x++, ++x x = x + 1
x--, --x x = x - 1
-x Reverses the sign of x

The operators below and on the right will be referred to in lesson 8 when you learn about condition statements.

Operator Description
&& and
|| or
! not
Operator Description
= = is equal to
!= is not equal to
> is greater than
< is less than
>= is greater than or equal to
<= is less than or equal to
back button
next button

© 2002 Tracy Johnson