title: 'Unexpected token d' when trying to add objects to a Javascript Object array
body: <p>I have an empty object within <code>hotKeyService</code> as below:</p>
  
  <pre><code>{hotKeys: [
      ]
  }
  </code></pre>
  
  <p>I want to add a load of objects into this array, to give an end result of the form:</p>
  
  <pre><code>{hotKeys: [
         "demoBtn1":{
                     keyCode: 49,
                     keyShortcut: "1",
                     label: "button"
                    },
         "demoBtn2":{
                     keyCode: 50,
                     keyShortcut: "2",
                     label: "button"
                    },
      ]
  }
  </code></pre>
  
  <p>Currently my code is:</p>
  
  <pre><code>hotKeyService.hotKeys.push(attrs.id);
  var arrayRow = hotKeyService.hotKeys.length - 1;
  var currentObj = JSON.parse(hotKeyService.hotKeys[arrayRow]);
  currentObj.keyCode = attrs.keyCode;
  currentObj.keyShortcut = attrs.keyShortcut;
  currentObj.label = attrs.label;
  </code></pre>
  
  <p>At the point where I try and parse JSON for <code>currentObj</code>, I receive the error. If I do not parse I get a <code>Cannot assign to read only property 'keyCode' of demoBtn1</code> error, which I read is because the object needs parsing.</p>
  
  <p>How do I populate the object as I am expecting?</p>
  
  <p>Thanks</p>