Assignment operators, in their most basic form, apply data to a variable. In this example, I’ll assign the string “Europe” to the variable continent.
var continent = "Europe";
Assignment is represented by the equals sign (=). Although there are other types of assignment operators, which you can view here, this is by far the most common.
You can test all the examples throughout this article by using the console.log() function, or by using the Console.
The addition operator, represented by a plus sign (+), will add two values and return the sum.
var x = 2 + 2; // x returns 4
The subtraction operator, represented by a minus sign (-), will subtract two values and return the difference.
var x = 10 - 7; // x returns 3
The multiplication operator, represented by an asterisk (*), will multiply two values and return the product.
var x = 4 * 5; // x returns 20
The division operator, represented by a forward slash (/), will divide two values and return the quotient.
var x = 20 / 2; // x returns 10
Slightly less familiar is the modulus operator, which returns the remainder after division, and is represented by the percentage sign (%).