简体   繁体   English

索引的JavaScript性能

[英]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. 即使Javascript中的哈希查找为O(1)(我不确定),您仍然会有查找操作的开销。 So, yes, this is suboptimal for a big loop. 因此,是的,这对于大循环而言不是最佳的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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