zoukankan      html  css  js  c++  java
  • 原生js学习笔记(一)易混淆重点

    js中有5种数据类型:Undefined、Null、Boolean、Number和String。 还有一种复杂的数据类型Object

    []转换成Number 为0 转换成boolean为true 所以![]==[] 是true 因为左边隐式转换等于false=0 右边也为0

    “” null 0 NaN undefined为false

     [] {}为true

    parseInt(11,2) ==3  11是3的2进制数

    parseInt(3,8) ==3   parseInt(3,2) ==NaN parseInt(3,0) ==NaN或3(谷歌浏览器把0看成默认的10)

    charCodeAt查看编码

    var str ="abc123呵呵";str.charCodeAt(0)==97;

    类型转换:有字符串转成string字符串 12+‘12’==‘’1212‘’ 有-*/%    +/-正负号强转成number 12-‘’12‘==0’    a=“abc”为string  -a为number  加!强转boolean

    “12”+1+1==“1211”  1+1+“12”==212

    undefined==0 为false  null==0为 false  null==undefined 为true

    typeof(a)=="String"为false typeof(a)=="string"为true7

    NaN不等于任何东西包括自己   “1”==1true  “1”===1false

    parseInt(“123abc”)=123 碰到字符串停止 “abc123”=NaN

    toFix()保留几位小数

    typeof(NaN)==number

    typeof(null) ==object 但null instanceof Object为false

    typeof(undefined) ==undefined

    typeof(a)== undefined

    typeof(NaN)==number

    typeof(typeof(undifined))== string

    round(11.5)==12  round(-11.5)==-11  round等于floor(n-0.5)

    typeof 1;  number                          void 0;  undefined

    typeof (1); number                           void (0);  undefined

    typeof ();  SyntaxError 语法错误              void (); SyntaxError 语法错误  

  • 相关阅读:
    AI编辑SVG格式的相关问题
    HTML里的id等属性命名需要注意
    canvas绘图动画细节
    触控获取坐标判断滑动方向
    CSS3卡片旋转效果
    使用CURL下载远程文件保存到服务器
    微信JS-SDK应用DEMO
    布局转换:文档流->绝对定位
    ThinkPHP缓存微信公众号access_token
    JAVA JSP笔记
  • 原文地址:https://www.cnblogs.com/litiane/p/12534447.html
Copyright © 2011-2022 走看看