JS运算符/条件语句/类型转换

1.运算操作符:

  +-*/%=,()

  ++--+=-=*=/=%=

2.条件语句:

  if,if else for(),while(),switch(){case :;}break,continue

3.js中判断为false的值:

  “”,false,0null,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.四舍五入:

  (1Math.ceil()执行向上舍入;

  (2Math.floor()执行向下舍入;

  (3Math.round()执行标准舍入;

  (4parseInt();小数取整;

10.输出数据:

  (1console.log()

  (2alert()document.write()/document.writeln()

  (3alert()//弹窗;取消;

  (4confirm();//弹窗;确定/取消;

11.类型转换:

  1.显示类型转换:

    (1) Number(mix);    undefined=NaN;  "abc123"=NaN;

    (2) parseFloat(string,radix);    整型,radix进制的string转为10进制;

    (3) parseFloat(string);    返回第一个数字;

    (4) toString();    不能转换nullundefined,但是能在括号内转进制;

    (5) String(mix);    能转nullundefined,但是不能转进制;

    (6) Boolean( );

  2.隐式类型转换:

    (1) isNaN()  ;    Number()

    (2) ++/--    +/-  ;    Number()

    (3) +  ;    有一方为String则为String

    (4) - * / %;    Number()

    (5) && || !  ;    Boolean()

    (6) < > <= >=

    (7) == !=

posted @ 2019-06-24 20:08  开拖拉机的拉风少年  阅读(103)  评论(0编辑  收藏  举报