A lot of people are suggesting using the JSON.parse function, however it is not a valid json format. So it would simply return
SYNTAX ERROR: Unexpected token a in JSON
What else comes to mind is using the eval function, but then again it would not work as the second parameter (2) isn't valid key in an object.
That being said we have to come up with some form of a transform function
You can use splits to divide the function into separate parameters, and then use replace to remove the unnecesery spaces/brackets
var str = "{ a: 1, 2: 10, c: 3 }";
Object.assign({}, ...str.split(",").map(param => {
param = param.replace("{", "").replace("}", "").split(":")
.map(a=>a.replace(" ", ""));
let object = {};
object[param[0]]=param[1];
return object;
}))
//returns {'2': 10, a: 1, c: 3}
after that assigning first part before the ":" to a key and the other part to the value is pretty straight forward. I then combine the smaller objects with one parameter each into a bigger one with object.assign.