首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

判断是不是为普通的对象

2012-08-24 
判断是否为普通的对象isPlainObject:function (o) { /*** toString.call(node) : ie678 [object Objec

判断是否为普通的对象

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就是你要判断的“对象(目标)”。

热点排行