title: Is there a limit on length of the key (string) in JS object?
body: <p>So we had a case where we would have an object, where key is id (int) and the value is the string. But we noticed that most of the times, we look up id based on the string, so we decided to reverse it and make a string the key and the value is the id. Because that way instead of going through each item and compare values, we could just do <code>var id = storage[text];</code>. Below are the examples of what we did.</p>
  
  <p>Here's the example of the old implementation:</p>
  
  <pre><code>var storage = {
    0 : null,
    1 : "Hello",
    2 : "world!",
    3 : "How are you?"
  }
  </code></pre>
  
  <p>Here's the example of the new implementation:</p>
  
  <pre><code>var storage = {
    "null" : 0,
    "Hello" : 1,
    "world!" : 2,
    "How are you?" : 3
  }
  </code></pre>
  
  <p>I understand that now the string is the key and it's ok to get the same id for the same strings. But since now the string can be potentially pretty huge (slim chance, but probably max 1KB per string), <strong>is there a length limit JS or Android webview puts on the object keys?</strong></p>
  
  <p>And also, does this implementation have disadvantages? I haven't noticed any issues so far, but you never know.</p>