title: Split javascript object with key value as written as strings
body: <p>The code pattern reads the <code>dataset</code> on the HTML element and receives the following output.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var objectString = '{"name": "Name", "description": "desc", "extra": "extra"}'
    
  console.log(typeof objectString)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can you please suggest an efficient way to convert it to key: value pair?</p>
  
  <p>Since <code>JSON.parse(objectString)</code> later results in </p>
  
  <blockquote>
    <p>SyntaxError: Unexpected token o in JSON at position 1</p>
  </blockquote>
  
  <p>It supposes that the is already an object, but doing <code>objectString.name</code> returns in <code>undefined</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My apologies, JSON.parse does work in the browser. But I didn't mention that the code project has jest tester verifying it, so it throws and Syntax Error. That's why I am looking for a similar approach. </p>
  
  <p>Is it possible to split the string words, loop over and return an object with as <code>key: pair</code>?</p>