比如 array 的 join 等 js 原有的 成员 就 for in 不出来啊!,但 alert("join" in new Array()); 为true. 我就想他 for in 不出来!!!!!
兄弟,这是做不到的。IE我不知道,不过看看FF是怎么说的吧:http://topic.csdn.net/u/20090304/15/4b55954a-9291-43b6-8fd2-5b3e2e10045d.htmlArrays Although it may be tempting to use this as a way to iterate over Array elements, because the for...in statement iterates over user-defined properties in addition to the array elements, if you modify the Array object, such as adding custom properties or methods, the for...in statement will return the name of your user-defined properties in addition to the numeric indexes. Thus it is better to use a traditional for loop with a numeric index when iterating over arrays.
修改不了上面的帖子,不过重点是这句: because the for...in statement iterates over user-defined properties in addition to the array elements
我就想他 for in 不出来!!!!!
兄弟,这是做不到的。IE我不知道,不过看看FF是怎么说的吧:http://topic.csdn.net/u/20090304/15/4b55954a-9291-43b6-8fd2-5b3e2e10045d.htmlArrays
Although it may be tempting to use this as a way to iterate over Array elements, because the for...in statement iterates over user-defined properties in addition to the array elements, if you modify the Array object, such as adding custom properties or methods, the for...in statement will return the name of your user-defined properties in addition to the numeric indexes. Thus it is better to use a traditional for loop with a numeric index when iterating over arrays.