Operators are the symbols between values that allow different operations like addition, subtraction, multiplication, and more.
+ operator adds two numbers.
1 + 2;
- operator subtracts one number from another.
50 - 15;
* operator multiplies two numbers. Notice it’s an asterisk and not the
× symbol commonly used in math.
3 * 12;
/ operator divides one number by another. Notice it’s a forward slash and not the
÷ symbol commonly used in math.
12 / 4;
+ is written first in the following example, the multiplication happens first between the last two numbers and
1 + 100 * 5;
If want more control over the order, that’s where the grouping operator comes in handy.
Adding the grouping operator to the previous example causes
1 + 100 to evaluate first.
(1 + 100) * 5;
+ operator can also concatenate strings, which is another way of saying it can add them together.
"news" + "paper";
= operator assigns values. It’s used for setting the value of variables.
var dinner = "sushi";