WEB DEVELOPER SITE

# JavaScript Operators

operator = Used for assignment.

The operator + is used to add values.

operator = Used to assign a value to a JavaScript variable.

The arithmetic operator + is used to add values.

### 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 Operators are utilized to perform math on numbers (literals or variables).

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

The addition Operator (+) includes numbers:

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

The multiplication Operator (*) increases numbers.

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

### JavaScript Assignment Operators

Assignment Operators 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 Operator (=) relegates an incentive to a variable.

### Assignment

var x = 10;

The addition assignment Operator (+=) increases the value of a variable.

var x = 10;
x += 4;

### JavaScript String Operators

The + operator is used to add (concatenate) text values or string variables. To concatenate two or more string variables, use the + operator.

To add a space between two strings, you need to insert a space into a string:

### Example

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

The aftereffect of txt3 will be:

John Doe

The += task Operator 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 »

Add two numbers and return the sum of the numbers. If the numbers are added to the string, return the string, as in the following example:

### Example

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

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

10
44
Hello4
Rule: If you add numbers to strings, the result will be strings!

Welookups is optimized for learning.Copy right 3014 kumar aditya singh .
All Right Reserved and you agree to have read and accepted our term and condition.