简体   繁体   中英

Javascript performance of indexing

以下行是否被认为不是最佳行,特别是考虑到它已在许多地方或循环内使用:

var age = myObject[index]["Person"]["Identity"]["Bio"]["Age"]

Even if hash lookup in Javascript is O(1) (I don't know for sure), you'd still have the overhead of the lookup operations. So, yes, this is suboptimal for a big loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM