...

View Full Version : simple enumeration question



realtimethrill
08-19-2008, 06:54 AM
Hi
According to JavaScript: The Good Parts, "The for in statement can loop over all of the property names in an object. The enumeration will include all of the properties—including functions and prototype properties", but when I try:


var x;
var mystr = new String("abc");
for (x in mystr) {
document.writeln(x + ':' + mystr[x] + "<br/>");
}

in IE I get nothing output at all and in FF2 I get 0:a 1:b 2:c -but no functions. I was wondering why all the properties of the String object e.g. chartAt() and indexOf() etc. aren't displayed?

Thanks!

Trinithis
08-19-2008, 07:16 AM
Many built-in properties do not enumerate.

realtimethrill
08-20-2008, 02:20 AM
thanks :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum