全局函数不能被迭代

/*
官网原文:
     In JScript, global functions cannot be iterated using the global this object. 
   Example:
*/
 <script> 
       var __global__ = this; 
       function invisibleToIE() 
       { 
           document.write("IE can't see me"); 
       }
        __global__.visibleToIE = function() 
       { 
            document.write("IE sees me"); 
       } 
       for (func in __global__) 
       { 
           var f = __global__[func]; 
           if (func.match(/visible/)) 
           { 
               f(); 
           }
       } 
</script> 
/*
    Output: 
            IE: IE sees me 
            FF: IE sees meIE can't see me 
            Opera: IE can't see meIE sees me 
            Safari: same as Opera IE incorrectly 

/*
官网原文:
      IE incorrectly implements the delete operator when applied to the global object. Attempting to execute delete this.invisibleToIE in the example below produces a runtime error (object doesn‟t support this action) in IE while in FF delete returns false. The FF behaviour seems correct according to §11.4.1, §10.2.1, and §8.6.2.5
Example:
*/
<script> 
      var __global__ = this; 
      function invisibleToIE() 
      { 
          document.write("IE can't see me"); 
      } 
      __global__.visibleToIE = function() 
      { 
            document.write("IE sees me"); 
      }
      document.write(delete this.invisibleToIE); 
</script> 
/*
    Output:
            IE: runtime error (object doesn‟t support this action) 
            FF: false 
            Opera: same as FF 
            Safari: same as FF
*/

/*
官网原文:
      In IE the global object does not inherit from Object.prototype even though its “type” is object. §15 – paragraph 8 seems to imply that the “Global Object” should inherit from Object.prototype (the value of its [[Prototype]] property is implementation dependent, but what ever it is it must be a “built-in prototype” and hence must follow the rules of paragraph 8. Of the standard methods of Object.prototype, the only one support by the global object in IE is toString Example: 
*/
<script> 
      var __global__ = this; 
      document.write(typeof(__global__) + '<br>'); 
      var f =['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable']; 
      for (i = 0; i < f.length; i++) 
      { 
          test(f[i]); 
      } 
      function test(s) 
     { 
           if (__global__[s]) 
          { 
               document.write(s + ' supported' + '<br>'); 
          } 
     } 
</script> 
/*  Output: 
         IE: object toString supported
         FF: object toString supported toLocaleString supported valueOf supported hasOwnProperty supported isPrototypeOf supported propertyIsEnumerable supported 
         Opera: same as FF 
         Safari: same as FF
*/

你可能感兴趣的:(IE,Opera,prototype,F#,Safari)