web建站教程
     
  1. 首页
  2. 前端UI组件库
  3. AI项目和框架
  4. 前端知识
  5. AI应用
  6. IT知识
  7. Chrome插件
  8. 地图大全
  9. 休息站

js如何获取当前对象的类型(number/string/boolean)

811 ℃

javascript如何利用方法获取当前对象是numberstringboolean等。下面web建站小编给大家详细介绍一下代码!

实例​代码如下:

console.log( typeof '1234' );  //检测数字1234,结果为:string
console.log( typeof 1 );  //检测数字1,结果为:number
console.log( typeof true );   //检测true,结果为:boolean
console.log( typeof false );  //检测false,结果为:boolean
console.log( typeof undefined );  //检测undefined,结果为:undefined
console.log( typeof null );  //检测null,结果为:object
console.log( typeof {} );  // 检测对象,结果为:object
console.log( typeof [] );  //检测数组,结果为:objec

js中typeof语法有什么作用

jquery如何判断某个元素是否存在(判断元素是否存在某个属性)

标签: typeof

上面是“js如何获取当前对象的类型(number/string/boolean)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_2730.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 首页 > js
扣子空间 – 免费全能AI办公智能体
Trae:新一代免费的AI编程工具
上一篇:
下一篇:
x 打工人ai神器
x 扫一扫打开藏历小程序

打开微信“扫一扫”查看今日藏历!