How to convert string to array of object in JavaScript?

To convert string to array of object in JavaScript, we use the JSON.parse method.

For instance, we write

const jsonString = '{ "a": 1, "b": 2 }';
const myObject = JSON.parse(jsonString);

to call JSON.parse with jsonString to convert jsonString into an object.