What's the fastest way to iterate over an object's properties in Javascript?

后端 未结 8 1685
旧巷少年郎
旧巷少年郎 2020-12-13 00:25

I know that I can iterate over an object\'s properties like this:

for (property in object)
{
    // do stuff
}

I also know that the fastest

相关标签:
8条回答
  • 2020-12-13 01:03

    If you don't know the names of the properties, for..in is a good way to enumerate them. If you do, you're better off with explicit dereference.

    0 讨论(0)
  • 2020-12-13 01:04

    An object's properties are unordered by definition. The lack of order means that there is no "forwards", and therefore there is no "backwards" either.

    0 讨论(0)
提交回复
热议问题