Latest web development tutorials

# JavaScript Operators

= Operator for assignment.

+ Operator for VAT.

= Operator is used to JavaScript variable.

Arithmetic operator + is used to add value.

## Examples

Specify the value of the variable, and the values ​​are added:

y=5;
z=2;
x=y+z;

After the above statement is executed, the value of x is:

7

try it"

## JavaScript Arithmetic Operators

y = 5, the following table explains these arithmetic operators:

+ 加法 x=y+2 7 5 实例 »
- 减法 x=y-2 3 5 实例 »
* 乘法 x=y*2 10 5 实例 »
/ 除法 x=y/2 2.5 5 实例 »
% 取模（余数） x=y%2 1 5 实例 »
++ 自增 x=++y 6 6 实例 »
x=y++ 5 6 实例 »
-- 自减 x=--y 4 4 实例 »
x=y-- 5 4 实例 »

## JavaScript Assignment Operators

JavaScript assignment operator is used to assign values ​​to variables.

Given x = 10 and y = 5, the table below explains the assignment operator:

= x=y x=5 实例 »
+= x+=y x=x+y x=15 实例 »
-= x-=y x=x-y x=5 实例 »
*= x*=y x=x*y x=50 实例 »
/= x/=y x=x/y x=2 实例 »
%= x%=y x=x%y x=0 实例 »

## + Operator for string

For the connection of two or more string variables together, use the + operator.

## Examples

For the connection of two or more string variables together, use the + operator:

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

txt3 operation results are as follows:

What a verynice day

try it"

To increase the space between two strings, we need to insert spaces into a string:

## Examples

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

After the above statement is executed, the value of the variable txt3 included are:

What a very nice day

try it"

Or the space into the expression ::

## Examples

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

After the above statement is executed, the value of the variable txt3 included are:

What a very nice day

try it"

Two numbers together and returns the sum of the numbers and, if the numbers are added and the string and returns a string following examples:

## Examples

x=5+5;
y="5"+5;
z="Hello"+5;

x, y, and z output is:

10
55
Hello5

try it"

Rule: If the sum of the numeric string, the result will be a string!