Best solution to convert String to object is using JSON parse() method in JavaScript. Create a variable and use JSON.parse(“string”) to have it converted into an object.
JSON.parse(text[, reviver]);
Example String to object JavaScript
Simple example code.
<!DOCTYPE html>
<html>
<body>
<script>
var string = '{"firstName":"name1", "age":30, "City":"NY"}';
var myobj = JSON.parse(string);
console.log(myobj);
</script>
</body>
</html>
Output:

If JSON string without the curly braces.
var string = "{firstName:'name1', lastName:'last1'}";
eval('var obj='+string);
console.log(obj);
Output: Object { firstName: “name1”, lastName: “last1” }
Do comment if you have any doubts or suggestions on this JS Object topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version

Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.