JS 操作符
来源:互联网 发布:推塔网络游戏要网络吗 编辑:程序博客网 时间:2024/06/06 01:08
Arithmetic Operators
算术运算符
加 x=2
y=2
x+y 4 - Subtraction
减 x=5
y=2
x-y 3 * Multiplication
乘 x=5
y=4
x*y 20 / Division
除 15/5
5/2 3
2.5 % Modulus (division remainder)
余数 5%2
10%8
10%2 1
2
0 ++ Increment
递增 x=5
x++ x=6 -- Decrement
递减 x=5
x-- x=4
Assignment Operators
赋值运算符
Comparison Operators
比较(关系)运算符
等于 5==8 returns false === is equal to (checks for both value and type)
等于(检查值和类型)*全吻合才算相等 x=5
y="5"
x==y returns true
x===y returns false
不等于 5!=8 returns true > is greater than
大于 5>8 returns false < is less than
小于 5<8 returns true >= is greater than or equal to
大于等于 5>=8 returns false <= is less than or equal to
小于等于 5<=8 returns true
Logical Operators
逻辑运算符
与 x=6
y=3
(x < 10 && y > 1) returns true
|| or或 x=6
y=3
(x==5 || y==5) returns false
! not非 x=6
y=3
!(x==y) returns true
String Operator
串符(连接作用)
A string is most often text, for example "Hello World!". To stick two or more string variables together, use the + operator.
在文字当中使用的比较多,举例来说“Hello World!”要将两个或多个字符串变量衔接在一起的话就得使用 + 符号
txt1="What a very"txt2="nice day!"txt3=txt1+txt2
The variable txt3 now contains "What a verynice day!".
txt3变量现在包含“What a verynice day!”(把1和2衔接起来了)
To add a space between two string variables, insert a space into the expression, OR in one of the strings.
要给两个字符串变量中间添加空格就得在表达式里插入空格,或在其中的一个加上(空格)
txt1="What a very"txt2="nice day!"txt3=txt1+" "+txt2
or
txt1="What a very "txt2="nice day!"txt3=txt1+txt2
The variable txt3 now contains "What a very nice day!".
现在变量txt3为“What a very nice day!”
Conditional Operator
条件运算符
JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
JS有根据条件不同给变量不同值的条件运算符
Syntax
语法
variablename=(condition)?value1:value2
Example
例子
greeting=(visitor=="PRES")?"Dear President ":"Dear "
If the variable visitor is equal to PRES, then put the string "Dear President " in the variable named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting.
如果变量visitor的值等于PRES那么greeting的值就为"Dear President "。如果不为PRES那么greeting的值就为"Dear"
- JS 操作符
- js new操作符
- js 移位操作符
- JS操作符
- [JS] new操作符
- JS new 操作符
- js 三元操作符
- JS-热身,操作符
- js--new操作符
- js new操作符
- js中的操作符
- js操作符优先级
- JS 中 new 操作符
- JS 中 new 操作符
- JS 中 new 操作符
- js基础之--操作符
- JS 中 new 操作符
- js中的typeof 操作符
- 通过代码动态注册OCX控件
- JTabbedPane的使用
- Asp.net 文件上传基类(取得文件后缀名,保存文件,加入文字水印)
- 数据库开发中应注意的地方
- Asp.net 数据采集
- JS 操作符
- FTP的2种工作模式(port and passive)
- winform下拉框篇.类似Word的颜色下拉框
- UI行业常用名词及缩写定义
- mysql xml http://libmyxql.sourceforge.net/
- JS Popup Boxes
- 给图片加上带版权的水印
- 对于update命令只有vfp9支持
- JS 函数