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)
相关推荐
2301_789015622 小时前
DS进阶:AVL树
开发语言·数据结构·c++·算法
Filotimo_3 小时前
5.3 Internet基础知识
开发语言·php
识君啊3 小时前
Java异常处理:中小厂面试通关指南
java·开发语言·面试·异常处理·exception·中小厂
qyzm5 小时前
天梯赛练习(3月13日)
开发语言·数据结构·python·算法·贪心算法
leluckys5 小时前
swift- Swift中常见的面试题
开发语言·汇编·swift
BUG_MeDe5 小时前
json格式字符串解析的简单使用 libjson-c
c语言·开发语言·json
唐叔在学习5 小时前
e.preventDefault()到底怎么用?
前端·javascript
CoderCodingNo6 小时前
【GESP】C++五级练习题 luogu-P1182 数列分段 Section II
开发语言·c++·算法
Highcharts.js6 小时前
Highcharts React v4.2.1 正式发布:更自然的React开发体验,更清晰的数据处理
linux·运维·javascript·ubuntu·react.js·数据可视化·highcharts