zoukankan      html  css  js  c++  java
  • js里的null 与undefined

      null 表示一个值被定义了,定义为'空值';

      undefined 表示没有定义。

      转换为数字时

        Number(undefined) === NaN

        Number(null) === 0

      在es6使用默认参数时,参数省略或为undefined,取参数默认值,参数为null,则对应参数赋值为nul

      

      设置一个值为null是合理的,设置一个值为undefined是不合理的,对一个不存在的属性取值全等undefined

      let obj={a:null};     

      obj.b===undefined  true

      let obj1={a:undefined};

      

      若你尝试对某元素引用一个该元素并不支持的事件,你会发现该元素的'on事件名'属性是undefined。但如果某事件被该元素所支持,但事件处理函数没设置,那么'on事件名'是null

      <button id='btn'>haha</button>

      var btn=document.getElementById('btn');

      console.log(btn.onclick)//null,button没有设置click事件处理程序
      console.log(btn.ondone) //undefined,button不支持done事件

      

      

  • 相关阅读:
    newCachedThreadPool无上限线程池使用
    newFixedThreadPool固定线程使用
    java定时器
    http文件上传/下载
    ThreadPoolExecutor线程池
    阻塞队列
    非阻塞队列
    IO文件夹拷贝(文件内含有文件和文件夹)
    MD5加密
    web.xml文件的作用
  • 原文地址:https://www.cnblogs.com/zhangtao1990/p/9430559.html
Copyright © 2011-2022 走看看