function isArray(o) {
    return Object.prototype.toString.call(o) === '[object Array]';
}

function isRegExp(o) {
    return Object.prototype.toString.call(o) === '[object RegExp]';
}

以上为示例,利用 Object.prototype.toString.call() 实现精确的类型判断;

相关文章:

  • 2021-12-11
  • 2021-08-18
  • 2021-12-10
  • 2022-12-23
  • 2021-11-19
  • 2021-11-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-20
  • 2021-11-20
  • 2021-09-29
  • 2021-11-27
  • 2021-12-12
相关资源
相似解决方案