WEB DEVELOPER SITE

# JavaScript Operators

### Example

Assign qualities to factors and include them together:

var x = 4;         //dole out the esteem 4 to x
var y = 3;         //relegate the esteem 3 to y
var z = x + y;     //allocate the esteem 7 to z (x + y)
Try it yourself »

### JavaScript Arithmetic Operators

Arithmetic administrators are utilized to perform math on numbers (literals or variables).

Operator Description
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
- - Decrement

var x = 4;
var y = 3;
var z = x + y;

The multiplication administrator (*) increases numbers.

var x = 4;
var y = 3;
var z = x * y;

### JavaScript Assignment Operators

Assignment administrators dole out qualities to JavaScript variables.

Operator Example Same As
= x = y x = y
+= x += y x = x + y
-= x - = y x = x - y
*= x *= y x = x * y
/= x/= y x = x/y
%= x %= y x = x % y

The assignment administrator (=) relegates an incentive to a variable.

var x = 10;

var x = 10;
x += 4;

### JavaScript String Operators

The + administrator can likewise be utilized to include (connect) strings.

### Example

txt1 = "John";
txt3 = "Doe";
txt3 = txt1 + " " + txt3;

The aftereffect of txt3 will be:

John Doe

The += task administrator can likewise be utilized to include (connect) strings:

### Example

txt1 = "What a very ";
txt1 += "nice day";

The consequence of txt1 will be:

What a decent day
Try it Yourself »

Adding two numbers, will restore the entirety, however including a number and a string will restore a string:

### Example

x = 4 + 4;
y = "4" + 4;
z = "Hi" + 4;

The consequence of x, y, and z will be:

10
44
Hello4