javascript判断数据类型

由于typeof 只能判断基本类型 string,number,boolean, undefined,object
利用 Object.prototype.toString.call 实现:
function type (obj) {
return Object.prototype.toString.call(obj).replace(/\[object\s|\]/g,'');
}
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/practice/1721/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
海报
javascript判断数据类型
由于typeof 只能判断基本类型 string,number,boolean, undefined,object
利用 Object.prototype.toString.call 实现:
function type (obj) {
return Objec……


共有 0 条评论