JS常见问题

文章目录

如何判断是数组

  1. Array.isArray
    console.log(Array.isArray(arr))
  2. instanceof(instanceof 运算符用于验证构造函数的 prototype 属性是否出现在对象的原型链中的任意位置)
    console.log(arr1 instanceof Array)
  3. constructor(实例的构造函数属性constructor指向构造函数)
    console.log(arr.constructor === Array)
  4. Object.prototype.toString.call()
    Object.prototype.toString.call(arr) === '[object Array]');
  5. 原型链
    arr.__proto__ === Array.prototype
  6. Array.prototype.isPrototypeOf(isPrototypeOf用于判断 一个对象是否是另一个对象的原型)
    Array.prototype.isPrototypeOf(arr)
相关推荐
Dream Cosmos1 分钟前
C++ 多态上篇:从 virtual 到抽象类,彻底理解多态的使用
开发语言·c++
TheBestRucy2 分钟前
Python九阳神功之柒:数据分析三剑客·执剑问道
开发语言·python·数据分析
qq_3391911421 分钟前
go cpu占比高排查,cpu100%排查,go pprof cpu命令
开发语言·后端·golang
西西弗Sisyphus25 分钟前
Qt 配置文件图标和文件版本信息
开发语言·qt
秋田君32 分钟前
Qt_Qt(c++)开发中常见错误与解决方法
开发语言·c++·qt
夏霞1 小时前
c# 不支持的目标框架 解决方案
开发语言·c#
雄哥0071 小时前
java代码反编译CFR
java·开发语言·反编译·cfr
lsylalalala1 小时前
多线程(2)
java·开发语言·多线程
jimy11 小时前
右值大类rvalue的xvalue,和 左值大类glvalue的xvalue的区别
开发语言·c++
geovindu1 小时前
CSharp: Template Method Pattern
开发语言·后端·c#·.net·模板方法模式·行为模式