在js中 undefined  null的区别是什么

解决方案 »

  1.   

    undefined is returned when you use either a variable that has been declared but never had a value assigned to it or an object property that does not existnull is usually considered a special value of object typea value that represents no objectnull更多的是强调其类型不同于string,object,array,boolean等。
      

  2.   

    google了一下:这个讲得很清楚:)http://saladwithsteve.com/2008/02/javascript-undefined-vs-null.html
      

  3.   

    不存在的就是undefined,有两种情况,对象的属性不存在,或变量没有声明并从未被赋值
    null是指变量或对象属性存在但未初始化(没有有效值)或赋予null值的
      

  4.   


    alert(null==undefined);//true
    alert(null === undefined);//false