• IE中不可遍历的属性


    IE的for...in循环存在严重的缺陷,除了性能低下外,有许多属性不可遍历,著名有这三兄弟:constructor ,toString ,valueOf。但实际情况更恐怖。下面是来自火狐官网的测试代码:

    var ret = (function(){
    var obj = {
        constructor : function() { return "0"; }
        ,toString : function() { return "1"; }
        ,valueOf : function() { return "2"; }
        ,toLocaleString : function() { return "3"; }
        ,prototype : function() { return "4"; }
        ,isPrototypeOf : function() { return "5"; }
        ,propertyIsEnumerable : function() { return "6"; }
        ,hasOwnProperty : function() { return "7"; }
        ,length: function() { return "8"; }
        ,unique : function() { return "9" }
    };
     
    var result = [];
    for(var prop in obj) {
    	result.push(obj[ prop ]());
    }
    
    return result.join("");
    })(); 
    

    结果:

    IE6 IE8 FF3.6 opera10 chrome4 safari4
    489 489 0123456789 0123456789 0123456789 0123456789
  • 相关阅读:
    浏览器原理
    jQ插件编写
    [转]清理浮动的全家
    百度面试~~
    LeetCode-222. Count Complete Tree Nodes
    LeetCode-236. Lowest Common Ancestor of a Binary Tree
    LeetCode-235. Lowest Common Ancestor of a Binary Search Tree
    LeetCode-102. Binary Tree Level Order Traversal
    LeetCode-404. Sum of Left Leaves
    LeetCode-257. Binary Tree Paths
  • 原文地址:https://www.cnblogs.com/rubylouvre/p/1642978.html
Copyright © 2020-2023  润新知