typeof(undefined) == undefined 成立吗?

1、问题:在Javascript中,typeof(undefined) == undefined成立吗?

答案:不成立,全局函数 typeof()返回值类型为字符串类型,六个可能值:
"number", "string", "boolean", "object" ,"function", 和 "undefined"。

只有

typeof(undefined) =="undefined";

才是成立的。

2、typeof(null) == ‘undefined’成立吗?

答案:不成立,null是Object类型的数据,故typeof(null) == ‘object‘成立。

3、typeof([1,2]) == ‘array‘成立吗?

答案:不成立,typeof()返回值没有"array" 类型,同样也没有“date”类型。

4、undefined == undefined成立吗?

答案:成立。

5、null == null成立吗?

答案:成立。

6、NaN == NaN成立吗?

答案:不成立。NaN 不与任何值相等,包括其本身。要检测值是否为 NaN,请使用
isNaN
函数。

7、typeof(NaN) == ‘number‘成立吗?

答案:成立。NaN是属于Number类型的数据。

终上所述,null是Object类型的数据,NaN是Number类型的数据,undefined则是undefined类型的数据,即没有定义,找不到该对象或对象的属性和方法。

typeof(undefined) == undefined 成立吗?,布布扣,bubuko.com

时间: 2024-08-18 03:31:25

typeof(undefined) == undefined 成立吗?的相关文章

JavaScript基础学习-- typeof,null,undefined

null 在 JavaScript 中 null 表示 "什么都没有". null是一个只有一个值的特殊类型.表示一个空对象引用. var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; var person = null; document.getElementById("demo").innerHTML = ty

selenium调用Firefox和Chrome需要注意的一些问题,和出现的报错selenium:expected [object undefined] undefined to be a string

在高版本selenium下如:selenium3.4.3 1.高版本的selenium需要浏览器安装一些补丁驱动 Firefox:geckodriver 下载网址:http://download.csdn.net/detail/ztzy520/9725887 或https://github.com/mozilla/geckodriver/release 如:geckodriver-v0.14.0-win32 Chrome:chromedriver 下载网址:http://chromedriver

V8 的 typeof null 返回 "undefined" 的 bug 是怎么回事

1997 年,IE 4.0 发布,带来的众多新特性中有一个对未来“影响深远”的 DOM API:document.all.在随后的 6 年里,IE 的市场占有率越来越高,直到 2003 年的 95%. 在这段时间里,产生了两种成千上万的页面.第一种:IE only 的页面,由于超高的市场占有率,开发人员觉得根本不需要考虑兼容性,于是直接使用 document.all,比如: document.all(foo).style.visibility = "visible" 甚至很多网站直接在

JavaScript typeof, null, 和 undefined

JavaScript 数据类型 在 JavaScript 中有 5 种不同的数据类型: string number boolean object function 3 种对象类型: Object Date Array 2 个不包含任何值的数据类型: null undefined 例子: typeof "John"                 // 返回 string typeof 3.14                   // 返回 numbertypeof NaN      

使用 typeof 来检测对象是否undefined

需求 判断是否为undefined 解决 使用 typeof 来检测对象是否已定义: if (typeof Obj !== "undefined" && Obj !== null) JavaScript 中, null 用于对象, undefined 用于变量,属性和方法. 对象只有被定义才有可能为 null,否则为 undefined. 参考:http://www.runoob.com/js/js-mistakes.html 原文地址:https://www.cnbl

typeof与instanceof比较+undefined与null各种值的相互比较

1.typeof:返回一个字符串 根据typeof判断对象 表达式 返回值 typeof undefined 'undefined' typeof true 'boolean' typeof 123 'number' typeof "abc" 'string' typeof function() {} 'function' typeof {} 'object' typeof [] 'object' typeof null 'object' function f(...args) { c

undefined

概述 undefined有多重角色,通常情况下,我们所说的undefined都指的是全局对象的一个属性"undefined". 语法 undefined 描述 在JavaScript中,undefined这个词有多重含义.首字母大写的Undefined表示的是一种数据类型,小写的undefined表示的是属于这种数据类型的唯一的一个值.但这两种undefined都只能存在于文档或规范中,不能存在于JavaScript代码中.在JavaScript代码中,你看到的undefined最有可

Javascript中undefined,NaN等特殊比较

以下内容转自: http://blog.csdn.net/hongweigg/article/details/38090093 1.问题:在Javascript中,typeof(undefined) == undefined成立吗? 答案:不成立,全局函数 typeof()返回值类型为字符串类型,六个可能值: "number", "string", "boolean", "object" ,"function&quo

前端面试准备2----Javascript中的Undefined和null小结

JavaScript中有两个表示“空”的值,分别是Undefined和null: (1)Undefined 定义了一个全局变量,它的值是 undefined,这个变量也被称为undefined. 但是这个变量不是一个常量,也不是一个关键字.这意味着它的值可以轻易被覆盖. ES5 提示: 在 ECMAScript 5 的严格模式下,undefined 不再是可写的了. 但是它的名称仍然可以被隐藏,比如定义一个函数名为 undefined. 下面的情况会返回 undefined 值: 访问未修改的全