0

let us suppose we create an object and use it to store some data let x = {"john":true,"jack":true,"jim":false} , what is the time complexity when I try to do console.log(x["john"]). I have few doubts like, do objects perform similar to hash tables, can they be called hash tables, if not what is a very optimized way to implement a hash table in JavaScript

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Sagnik B
  • 29
  • 1
  • 3
  • 2
    And by JSON you mean an object. [What is the difference between JSON and Object Literal Notation?](https://stackoverflow.com/questions/2904131/what-is-the-difference-between-json-and-object-literal-notation) – Guy Incognito May 19 '20 at 06:12
  • JSON is *only* text. Same as XML - it's just a serialisation format. What you have is a plain JavaScript object. – VLAZ May 19 '20 at 06:13
  • I've been assuming they're implemented as hashtables, because anything else would be crazy. But I haven't written a big enough application to notice the difference – OpenSauce May 19 '20 at 06:15
  • https://stackoverflow.com/questions/1143498/difference-between-an-object-and-a-hash – bill.gates May 19 '20 at 06:15

0 Answers0