web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

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

419 ℃
     

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
本文共计427个字,预计阅读时长3分钟
生活小工具,收录了80多款小工具
上一篇: 介绍几款带有中国风古韵的免费可商用中文字体
下一篇: 推荐9款支持 Vue3 免费开源的前端 UI 组件库
x 打工人ai神器