Update for 2016
Since you are asking about node.js, and this is 2016, now you can use the Set or Map object from ES6 as they are built into ES6. Both allow you to use any string as a key. The Set object is suitable when you just want to see if a key exists:
if (mySet.has(someString)) { //code here }
And, Map is suitable if you want to save the value for this key, as in:
if (myMap.has(someString)) { let val = myMap[someString]; // do something with val here }
Both ES6 features are now built into node.js with node V4 (the current version of node.js starting with this edit is v6).
See this performance comparison to see how much faster Set operations do than many others.
Old answer
All important performance issues should be tested using real-world performance tests in a tool such as jsperf.com. In your case, the javascript object uses the hash table implementation as an implementation, because without something that works pretty well, the whole implementation will be slow, since many JavaScript uses the object.
The string keys on the object will be the first that I checked, and I would prefer the best performer. Since the internals of the object are implemented in native code, I expect it to be faster than your own hash table or binary search implemented in javascript.
But, as I began my answer, you should really check your specific circumstance for the number and length of lines that you are most concerned about in a tool like jsperf.
jfriend00
source share