当前位置: 首页 > backend >正文

数据类型检测有哪些方式?

  1. typeof 其中数组 对象 null都会判断为Object,其他正确
typeof  2    // number
typeof true   //bolean
typeof 'str'  //string
typeof [] //Object
typeof function (){}  // function
typeof {}  //object
typeof undefined  //undefined
typeof null  // null
  1. instanceof 判断引用类型,其内部机制就是判断其原型链上是否存在该类型的原型
2 instanceof Number  //false
true instanceof Boolean //false
'str' instanceof String  //false
[] instanceof Array //true
{} instanceof Object //true
function(){} instanceof Function //true
  1. constructor 对象访问它构造函数
(2).constructor === Number  //true
(true).constructor ==Boolean //true
  1. Object.prototype.toString.call()
Object.prototype.toString.call(2) == '[object Number]'
http://www.xdnf.cn/news/10522.html

相关文章:

  • robot_lab学习笔记【MDP综述】
  • QuickJS 如何计算黄金分割率 ?
  • barker-OFDM模糊函数原理及仿真
  • Linux防火墙:全面解析IPTables的表、链、规则!
  • Cypress + TypeScript + Vue3
  • 数据库管理与高可用-MySQL全量,增量备份与恢复
  • 劫持进程注入
  • C语言进阶--程序的编译(预处理动作)+链接
  • 数据结构:递归(Recursion)
  • 基于TMC5160堵转检测技术的夹紧力控制系统设计与实现
  • 输入ifconfig,发现ens33不见了,无法连接至虚拟机
  • Golang——3、流程控制语句
  • C++实现伽罗华域生成及四则运算(三)
  • Python----目标检测(《SSD: Single Shot MultiBox Detector》论文和SSD的原理与网络结构)
  • CppCon 2014 学习:C++ in Huge AAA Games
  • STM32F407寄存器操作(多通道单ADC+DMA)
  • 前端面试准备-5
  • Mask_RCNN 环境配置及训练
  • QT中子线程触发主线程弹窗并阻塞等待用户响应-传统信号槽实现
  • DRW - 加密市场预测
  • 考研系列—操作系统:第四章、文件管理(part.2)
  • 利用DeepSeek编写能在DuckDB中读PostgreSQL表的表函数
  • 多任务——进程
  • 基于机器学习的心脏病预测模型构建与可解释性分析
  • WIN11+VSCODE搭建的c/c++环境调试报错解决
  • vue+mitt的简便使用
  • API异常信息如何实时发送到钉钉
  • 重读《人件》Peopleware -(14)Ⅱ 办公环境 Ⅶ 把门带上
  • Windows商店中的免费扫雷游戏应用
  • 将手机网络经USB数据线和本地局域网共享给华为AP6050DN无线接入点