当前位置: 代码迷 >> Web前端 >> 判断是不是为普通的对象
  详细解决方案

判断是不是为普通的对象

热度:269   发布时间:2012-08-24 10:00:20.0
判断是否为普通的对象
isPlainObject:function (o) {
 /**
   * toString.call(node) : ie678 == '[object Object]',other =='[object HTMLElement]'
   * 'isPrototypeOf' in node : ie678 === false ,other === true
   */
     return o && toString.call(o) === '[object Object]' && 'isPrototypeOf' in o;
},

?

IE浏览器采用toString()方法检验,其他浏览器查看属性中是否有isPrototypeOf来判断,o就是你要判断的“对象(目标)”。

  相关解决方案