1.运算操作符:
+,-,*,/,%,=,()
++,--,+=,-=,*=,/=,%=
2.条件语句:
if,if else ,for(),while(),switch(){case :;},break,continue
3.js中判断为false的值:
“”,false,0,null,undefined,NaN
注:“false”为true。
4. typeof()识别的数据类型:
number,string,boolean,
undefined,object,function
5.三目运算符: ? :
条件判断?true:false; 并返回值
6.随机数:
Math.random(); 0-1;
7.判断是否汉字:
.charCodeAt(); //英文<=255,中文>255
8. with () {}; (此代码块运行缓慢,最好不用)
把()内的OA放到{}访问的最顶端;
9.四舍五入:
(1)Math.ceil()执行向上舍入;
(2)Math.floor()执行向下舍入;
(3)Math.round()执行标准舍入;
(4)parseInt();小数取整;
10.输出数据:
(1)console.log();
(2)alert();document.write()/document.writeln();
(3)alert();//弹窗;取消;
(4)confirm();//弹窗;确定/取消;
11.类型转换:
1.显示类型转换:
(1) Number(mix); undefined=NaN; "abc123"=NaN;
(2) parseFloat(string,radix); 整型,把radix进制的string转为10进制;
(3) parseFloat(string); 返回第一个数字;
(4) toString(); 不能转换null和undefined,但是能在括号内转进制;
(5) String(mix); 能转null和undefined,但是不能转进制;
(6) Boolean( );
2.隐式类型转换:
(1) isNaN() ; Number()
(2) ++/-- +/- ; Number()
(3) + ; 有一方为String则为String
(4) - * / %; Number()
(5) && || ! ; Boolean()
(6) < > <= >=
(7) == !=
原文:https://www.cnblogs.com/Tractors/p/11079180.html