五 typeof &类型转化

作者: WIN_Inn | 来源:发表于2018-09-13 21:53 被阅读2次

    typeof操作符

    number     string     boolean     object     undefined     function

    typeof ( typeof ( a ) )  ;      //a为定义,为字符串类型的undefined,"string"

    parseInt ( "101010",2) 以目标进制为基底转化为十进制

    parseInt ( "123abc")     ==> 123

    undefined 和 null 没有toString方法

    把101010转化成16进制  2 ->10 ->16

    var abc = parseInt ( "101010", 2 ) ;     var test = abc.toString( 16 );

    类型转换

    isNaN ( );         //  是否是非数    先隐式类型转化成Number, 再与NaN比较

    isNaN ( null );        --> true    //  因为Number ( null ) --> 0

    var a = "123";  a++;    a-->124    //先隐式类型转换成数字,再运算

    ++     --       +  / - ( 一元运算符 )  都会隐式类型转换成数字,转不成也会typeof出“number”

    undefined == null  //true

    undefined != 0   null != 0  但是 undefined == null

    typeof ( abc )  ==>  typeof  abc 

    相关文章

      网友评论

        本文标题:五 typeof &类型转化

        本文链接:https://www.haomeiwen.com/subject/mmdzwftx.html