zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【说站】js中typeof操作符是什么

JS 什么 操作符 typeof
2023-06-13 09:13:23 时间

js中typeof操作符是什么

1、typeof操作符返回字符串,表示未计算操作数的类型。

2、typeof一般用来检验简单的数据类型,返回的基本类型用字符串表示,而复杂的数据类型中function返回的是Function,其他的都返回Object,其中null特殊,表示一个空对象。

实例

typeof 1 // 'number'
typeof '1' // 'string'
typeof undefined // 'undefined'
typeof true // 'boolean'
typeof Symbol() // 'symbol'
typeof null // 'object'
typeof [] // 'object'
typeof {} // 'object'
typeof console // 'object'
typeof function(){} // 'function'

以上就是js中typeof操作符的介绍,希望对大家有所帮助。更多js学习指路:js教程

收藏 | 0点赞 | 0打赏