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 语法错误  

  • 相关阅读:
    为什么switch里的case没有break不行
    CLS的探索:Python如何让日志免费云化
    做一次“黑客“,入侵一次自己的服务器
    斥资288买了三年服务器之后应该如何配置
    Scrapy入门到放弃01:开启爬虫2.0时代
    c#自制抽奖小程序
    c#中的几种Dialog
    解决数据库排序空值排在前问题
    Oracle 数据库添加定时事件
    FileReader 对象实现图片预览
  • 原文地址:https://www.cnblogs.com/litiane/p/12534447.html
Copyright © 2011-2022 走看看