Complexity of accessing data in an object

前端 未结 2 564
慢半拍i
慢半拍i 2021-01-02 05:03

In some of the projects I\'m working on as part of my day job, I need to access data in very large JS objects (on the order of thousands of key-value pairs). I\'m trying to

2条回答
  •  死守一世寂寞
    2021-01-02 05:48

    Javascript objects are actually Hashes, so the complexity is O(1) for all engines.

    obj.field is an alias for obj['field'], so they have the same performances.

    You can find some JS hashes performance tests here, unfortunately only for your browser engine.

提交回复
热议问题