博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
typeof
阅读量:7021 次
发布时间:2019-06-28

本文共 1444 字,大约阅读时间需要 4 分钟。

Examples:

// Numberstypeof 37 === 'number';typeof 3.14 === 'number';typeof(42) === 'number';typeof Math.LN2 === 'number';typeof Infinity === 'number';typeof NaN === 'number'; // Despite being "Not-A-Number"typeof Number(1) === 'number'; // but never use this form!复制代码
// Stringstypeof "" === 'string';typeof "bla" === 'string';typeof (typeof 1) === 'string'; // typeof always returns a stringtypeof String("abc") === 'string'; // but never use this form!复制代码
// Booleanstypeof true === 'boolean';typeof false === 'boolean';typeof Boolean(true) === 'boolean'; // but never use this form!复制代码
// Symbolstypeof Symbol() === 'symbol'typeof Symbol('foo') === 'symbol'typeof Symbol.iterator === 'symbol'复制代码
// Undefinedtypeof undefined === 'undefined';typeof declaredButUndefinedVariable === 'undefined';typeof undeclaredVariable === 'undefined'; 复制代码
// Objectstypeof {a:1} === 'object';// use Array.isArray or Object.prototype.toString.call// to differentiate regular objects from arraystypeof [1, 2, 4] === 'object';typeof new Date() === 'object';// The following is confusing. Don't use!typeof new Boolean(true) === 'object'; typeof new Number(1) === 'object'; typeof new String("abc") === 'object';复制代码
// Functionstypeof function(){} === 'function';typeof class C {} === 'function';typeof Math.sin === 'function';// This stands since the beginning of JavaScripttypeof null === 'object';复制代码

转载于:https://juejin.im/post/5ac495b3f265da23830b1bc5

你可能感兴趣的文章
MySQL报错:Ignoring query to other database的解决办法
查看>>
安装办公室电脑监控的有哪些作用?
查看>>
20180706
查看>>
Centos7下安装Oracle 11gR2 数据库
查看>>
maven如何配置?(图解)
查看>>
Confluence 6 让一个空间可以公众访问
查看>>
Spring Batch JSON 支持
查看>>
nagios监控系统环境部署安装(LAMP环境)
查看>>
使用Runtime解决 cell 点击时子视图改变背景颜色的问题
查看>>
手机压缩PDF文件的简单方法
查看>>
华为--交换机VLAN划分与Trunk链路
查看>>
MATLAB编程与应用系列-第2章 数组及矩阵的创建及操作(3)
查看>>
ELF-B型三轴向加速度计
查看>>
使用anaconda和conemu打造Python编程环境
查看>>
企业家还需要学管理理论吗?
查看>>
必须装!Windows 7下月发布SHA-2加密算法补丁
查看>>
iOS即时通讯
查看>>
Spring Cloud Alibaba与Spring Boot/Cloud之间不得不说的版本关系
查看>>
docker详细的基础用法
查看>>
从VHD启动第二个操作系统
查看>>