JS基础——数据类型判断typeof、instanceof、Object.prototype.toString
栏目: JavaScript · 发布时间: 5年前
内容简介:对应测试结果如下:
typeof instanceof Object.prototype.toString
对应测试结果如下:
typeof test
|
instanceof
|
Object.prototype.toString.call(test)
|
|
var test = 'xuriliang'; | string |
test instanceof String //false
|
[object String] |
var test = 27; | number |
test instanceof Number //false
|
[object Number] |
var test = true; | boolean |
test instanceof Boolean //false
|
[object Boolean] |
var test = [1,2,3]; | object |
test instanceof Array //true
|
[object Array] |
test instanceof Object //true
|
|||
var test = null; | object |
test instanceof Object //false
|
[object Null] |
var test = undefined; | undefined |
test instanceof Object //false
|
[object Undefined] |
var test = new String('xuriliang') | object |
test instanceof String //true
|
[object String] |
test instanceof Object //true
|
|||
var test = new Number(27) | object |
test instanceof Number //true
|
[object Number] |
test instanceof Object //true
|
|||
var test = new Boolean(true) | object |
test instanceof Boolean //true
|
[object Boolean] |
test instanceof Object //true
|
|||
var test = new Array(1,2,3) | object |
test instanceof Array //true
|
[object Array] |
test instanceof Object //true
|
|||
var test = function(){} | function |
test instanceof Function //true
|
[object Function] |
test instanceof Object //true
|
|||
var test = /d/ | object |
test instanceof RegExp //true
|
[object RegExp] |
test instanceof Object //true
|
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
测试驱动开发的艺术
Lasse Koskela / 李贝 / 人民邮电出版社 / 20101023 / 59.00元
在传统的软件开发中,开发人员对于代码是否正确心中无底,一切依赖于后期的测试环节。极限编程反其道而行之,主张采用测试驱动开发(TDD)的方法,即通过测试定义所要开发的功能的接口,然后实现功能的开发过程。TDD通过不断地测试推动代码的开发,既简化了代码,又保证了软件质量。 本书采用“手把手”的教学方式,通过大量实例来解释TDD,还专门用几章的篇幅来讲解如何为难于测试的技术编写单元测试。全书内容循......一起来看看 《测试驱动开发的艺术》 这本书的介绍吧!