最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

The time-complexity of using object as a dictionary in JavaScript - Stack Overflow

programmeradmin1浏览0评论

I am considering using JavaScript object as a dictionary.

    var dict = {}
    dict['a'] = 1;
    dict['b'] = 2;

    var my_first = dict['a'];

I am not clear about the time-plexity of such implementation. Is it like hashing? Thank you.

I am considering using JavaScript object as a dictionary.

    var dict = {}
    dict['a'] = 1;
    dict['b'] = 2;

    var my_first = dict['a'];

I am not clear about the time-plexity of such implementation. Is it like hashing? Thank you.

Share Improve this question asked Jul 22, 2011 at 16:00 Wei AnWei An 2,0094 gold badges15 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

JavaScript objects are often called "hashes" (mostly by recovering Perl addicts) or "hash tables" (unrepentant Java people). The typical look-up is somewhere between O(1) and O(log n).

发布评论

评论列表(0)

  1. 暂无评论