Home > Web Front-end > JS Tutorial > body text

Javascript Common Operators (Operators)-Javascript Basics Tutorial_Basic Knowledge

WBOY
Release: 2016-05-16 19:07:03
Original
1108 people have browsed it

Javascript basic tutorial arithmetic operators

Operator Operator Description Example Example
Addition x y
运算符 运算符说明 示例 示例说明
加法 x y

如果x为整数2,y为整数5, x y等于7

如果x为字符串"text1", y为字符串"fun",

x y则等于"text1fun"

- 减法 x-y
* 乘法 x*y
/ 除法 x/y
% 两者相除求余数 x%y 如果x等于10, y等于3, x%y结果等于1
递增 x 如果x等于10, x 等于11
-- 递减 y-- 如果y等于10, y--等于9
If x is an integer 2 and y is an integer 5, x y is equal to 7

If x is the string "text1" and y is the string "fun",

x y is equal to "text1fun"

运算符 运算符说明 示例 示例说明
== 等于 x==y 如果x等于2, y等于2,则x==y
=== 全等于(值相等,数据类型也相等) x===y

如果x等于整数2,y为字符串"2",

则x===y不成立 

> 大于 x>y
>= 大于等于 x>=y
< 小于 x
<= 小于等于 x<=y
!= 不等于 x!=y
!== 不全等于 x!==y
&& 与(and) x < 10 && y > 1
! 非(not) !(x==y)
|| 或(or) x==8 || y==8
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Divide the two and find the remainder x%y If x equals 10, y equals 3, the result of x%y is equal to 1
Increment x If x equals 10, x equals 11
-- Decreasing y-- If y is equal to 10, y--is equal to 9

Javascript basic tutorial logical operators

Operator Operator Description Example Example
== equals x==y If x equals 2 and y equals 2, then x==y
=== All equal (the values ​​are equal and the data types are also equal) x===y
运算符 运算符说明 示例 示例说明
赋值 x=5 将整数5这个值赋给变量x
If x is equal to the integer 2, y is the string "2",

Then x===y is not true

> Greater than x>y
>= Greater than or equal x>=y
< less than x
<= Less than or equal x<=y
!= not equal x!=y
!== Not all equal x!==y
&& and(and) x < 10 && y > 1
! Not (not) !(x==y)
|| or(or) x==8 || y==8
Javascript basic tutorial assignment operator Note: Please pay attention to the difference between assignment (=) and equal (==).
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!