`
pstinghua
  • 浏览: 24099 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

for/in loop

阅读更多
JavaScript arrays are simply a specialized kind of object. Therefore, the for/in loop enumerates array
indexes as well as object properties.

The for/in loop does not specify the order in which the properties of an object are assigned to the
variable. There is no way to tell what the order will be in advance, and the behavior may differ among
implementations or versions of JavaScript. If the body of a for/in loop deletes a property that has not yet
been enumerated, that property will not be enumerated. If the body of the loop defines new properties,
whether or not those properties will be enumerated by the loop is implementation-dependent.
The for/in loop does not actually loop through all possible properties of all objects. In the same way that
some object properties are flagged to be read-only or permanent (nondeletable), certain properties are
flagged to be nonenumerable. These properties are not enumerated by the for/in loop. While all userdefined
properties are enumerated, many built-in properties, including all built-in methods, are not
enumerated.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics