undefined 声明的变量尚未初始化

null 对象尚未存在

eg:

var a;

console.log(typeof a);

输出undefined

var b= document.getElementById("b");

console.log(typeof b);

console.log(null== b);

第一行输出object! 这其实是javascript最早的一个错误,但被沿袭了下来...

第二行输出true,因为document.getElementById("b")并不存在

特别注意:

console.log(null== undefined);

输出的结果为true!因为undefined是null的派生

但console.log(null=== undefined);会输出false

undefined与null的更多相关文章

  1. JavaScript中undefined与null的区别

    通常情况下, 当我们试图访问某个不存在的或者没有赋值的变量时,就会得到一个undefined值.Javascript会自动将声明是没有进行初始化的变量设为undifined. 如果一个变量根本不存在会 ...

  2. 对于undefined和null,还有处理这一类的数组

    var total=0; var data=new Array(5);//定义了data数组,length为5,但是都是元素都是undefined. for(i=0;i<data.length; ...

  3. javascript类型系统——undefined和null

    × 目录 [1]原因 [2]undefined [3]null 前面的话 一般的程序语言,表示空的只有null,但javascript的设计者Brendan Eich却设计了一个undefined,这 ...

  4. SharePoint 2013 Error - TypeError: Unable to get property 'replace' of undefined or null reference

    错误信息 TypeError: Unable to get property ‘replace’ of undefined or null referenceTypeError: Unable to ...

  5. JS 中如何判断 undefined 和 null

    JS 中如何判断 undefined JavaScript 中有两个特殊数据类型:undefined 和 null,下节介绍了 null 的判断,下面谈谈 undefined 的判断. 以下是不正确的 ...

  6. 【温故而知新-Javascript】比较 undefined 和 null 值

    JavaScript 中有两个特数值: undefined和null,在比较它们的时候需要留心.在读取未赋值的变量或试图读取对象没有的属性时得到的就是 undefined 值. <!DOCTYP ...

  7. undefined与null的区别

    最近在默默的看面试题,其中有一个题目就是“undefined和null的区别”,突然意识到自己从未关注过这个问题,心中莫名有种急躁的感觉,百度一下发现阮大神的一篇文章(http://www.ruany ...

  8. 【JS Note】undefined与null

    在Javascript中有这两种原始类型: Undefined与Null.而这两种原始类型都各自只有一个值,分别是undefined,null. undefined: 1.变量声明后未赋值,则变量会被 ...

  9. 【转】JavaScript中undefined与null的区别

    通常情况下, 当我们试图访问某个不存在的或者没有赋值的变量时,就会得到一个undefined值.Javascript会自动将声明是没有进行初始化的变量设为undifined. 如果一个变量根本不存在会 ...

  10. Javascript数据类型——undefined和null的异同

    Javascript的基本数据类型中有undefined和null两种只有一个值得特殊数据类型.其中undefined表示未被初始化,不是为声明.而null表示一个空对象指针,而这也是使用typeof ...

随机推荐

  1. java 邮件发送 apache commons-email

    package com.sun.mail;import org.apache.commons.mail.Email;import org.apache.commons.mail.EmailExcept ...

  2. jquery 画板折叠

    <!doctype html><html lang="en"><head> <meta charset="utf-8" ...

  3. 一行一行分析JQ源码学习笔记-06

    节点类型获取$("span")首先 判断 if(select.nodeType) markarray() 类数组 转化成真正的数组 var adiv = document.getE ...

  4. hdu_5968_异或密码(预处理+二分)

    题目链接:hdu_5968_异或密码 题意: 中午,不解释 题解: 前缀处理一下异或值,然后上个二分查找就行了,注意是unsigned long long #include<bits/stdc+ ...

  5. (转) QImage总结

    嗯,这个QImage的问题研究好久了,有段时间没用,忘了,已经被两次问到了,突然有点解释不清楚,我汗颜,觉得有必要重新总结下了,不然无颜对自己了. 图像的数据是以字节为单位保存的,每一行的字节数必须是 ...

  6. webapi中的路由前缀

    Route Prefixes Often, the routes in a controller all start with the same prefix. For example: public ...

  7. maven入门(下)

    Apache Maven 入门篇(下) 作者:George Ma 第一篇文章大概的介绍了一下Apache Maven以及它的下载和安装,并且运行了一个简单的示例.那么在对maven有了一点接触后,接下 ...

  8. submit提交表单后,不刷新当前页面

    <form method="get" target="test" action="a.html"> <input type ...

  9. 当用反射获取一个model,这个model里面字段有nullable的时候,获取字段真实类型

    Using Reflection to Determine whether an Type is Nullable And Get the underlying Type /// <summar ...

  10. iOS SDWEBImage和collectionView的组合,以及collectionView的随意间距设置

    转载自:http://www.cnblogs.com/tmf-4838/p/5361271.html #import "ViewController.h" #import < ...