JS

适用范围:

1. 场景

  • 基本数据类型
  • js内置的类

2. 不适用场景

  • 用户自定义的类
    • 统一返回[object Object]
    • 包括继承的类
      • class MyArray extends Array {}这个会判定为所继承的类(即Array, 而不是 MyArray)

实例

Object.prototype.toString.call('Hello')//返回[object String]
Object.prototype.toString.call(false); //返回[object Boolean]
Object.prototype.toString.call(false); //返回[object Null]