ä»æ¥ã®ç¡éã«ã¼ã
次ã®ãããªã³ã¼ããæ¸ããããIE6ã§ç¡éã«ã¼ãã«!
// ãã¹ãç¨ãªãã¸ã§ã¯ã function Test() {} Test.prototype = { a: function() {}, b: function() {} } var test = new Test(); // for .. inã§ã«ã¼ã â IE6ã ã¨ç¡éã«ã¼ãã«! for ( var i in test ) { document.getElementById( "stdout" ).innerHTML += i + "<br/>"; test[i + "_org"] = function(){}; }
IE6ã®for .. inã«ã¼ãã§ã¯ãã«ã¼ãä¸ã«è¿½å ããããããã£ãåæããã¦ãã模æ§ããªã®ã§ãã«ã¼ãä¸ã§ãªãã¸ã§ã¯ãã«ããããã£ã追å ãã¦ããã¨ãç¡éã«ã¼ãã«é¥ãã¾ããâã¿ããã«ç´ãã¦å®è¡ããã¨ããããããã
function Test() {} Test.prototype = { a: function() {}, b: function() {} } var test = new Test(); // for .. inã§ã«ã¼ã var count = 0; for ( var i in test ) { document.getElementById( "stdout" ).innerHTML += i + "<br/>"; test[i + "_org"] = function(){}; // ç¡éã«ã¼ãã®æå¶ã100åã¾ã§! count++; if ( count > 100 ) { break; } }
確認はこちらã
Safari3.1,FireFox2.0,Opera9.26ã§ã試ãã¦ã¿ããã©ãã«ã¼ãéå§æã«åå¨ããããããã£ã®ã¿åæããç¡éã«ã¼ãã«ã¯ãªãã¾ããã§ãããææã¡ã®ç°å¢ã§ã¯IE6ã ãã£ã½ãã(IE7ã8ã¯è©¦ãã¦ãªãã§ãã)
ECMA Scriptã®ä»æ§(æ¥æ¬èªè¨³ã ãã©)ã§ã¯ãåæä¸ãªãã¸ã§ã¯ãã«æ°ããããããã£ã追å ããããªãã°ãæ°ãã«è¿½å ãããããããã£ã¯ç¾å¨ã®åæã«ããã¦æãããããã¨ãä¿è¨¼ãããªããã(âUnder Translation of ECMA-262 3rd Edition 日本語訳)ã¨ãªã£ã¦ãã¦ãã©ã£ã¡ã«ãªããã¯ä¿è¨¼ããã¦ããªãã¨ã®ãã¨ããµãã