次次看JavaScript权威指南中的enumeration都抓狂
每次看JavaScript权威指南中的enumeration都抓狂
好像我的知识体系里少了些什么。
------解决方案--------------------
到现在我都没有在javascript用过enumeration,看过enumeration。
在javascript中这些新奇玩意,看不到源代码,还真的不知所云。
不过我想用绝对会用,因为在java中看多了用多了。
------解决方案--------------------
Running this sample in Internet Explorer 8 and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1 second: prop2 3: prop3
All modes of Internet Explorer 9:
3: prop3 first: prop1 second: prop2
Internet Explorer 8 does not include enumerations of properties that have the same name as built-in properties of a prototype object. All document modes in Internet Explorer 9 include these properties in the enumeration. The following sample illustrates this difference:
Running this sample in Internet Explorer 8and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1
All modes of Internet Explorer 9:
first: prop1 toString: Hello
好像我的知识体系里少了些什么。
------解决方案--------------------
到现在我都没有在javascript用过enumeration,看过enumeration。
在javascript中这些新奇玩意,看不到源代码,还真的不知所云。
不过我想用绝对会用,因为在java中看多了用多了。
------解决方案--------------------
var obj = {first : "prop1", second: "prop2", 3: "prop3"};
var s = "";
for (var key in obj) {
s += key + ": " + obj[key] + " ";
}
document.write (s);
Running this sample in Internet Explorer 8 and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1 second: prop2 3: prop3
All modes of Internet Explorer 9:
3: prop3 first: prop1 second: prop2
Internet Explorer 8 does not include enumerations of properties that have the same name as built-in properties of a prototype object. All document modes in Internet Explorer 9 include these properties in the enumeration. The following sample illustrates this difference:
var obj = { first: "prop1", toString : "Hello" }
var s = "";
for (var key in obj) {
s += key + ": " + obj[key] + " ";
}
document.write (s);
Running this sample in Internet Explorer 8and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1
All modes of Internet Explorer 9:
first: prop1 toString: Hello