Object.prototype.tostring.call()

2020-09-12  本文已影响0人  黄黄黄大帅

typeof判断数据类型,只能区分基本类型,即:Number、String、undefined、Boolean、Object。
Object.prototype.toString

Object.prototype.toString.call(null); // "[object Null]"
Object.prototype.toString.call(undefined); // "[object Undefined]"
Object.prototype.toString.call(“abc”);// "[object String]"
Object.prototype.toString.call(123);// "[object Number]"
Object.prototype.toString.call(true);// "[object Boolean]"
上一篇 下一篇

猜你喜欢

热点阅读