String to array conversion in Javascript [duplicate]

I have a Javascript object:

{
    "answers": "[0,0,0,0,1]"
}

I want to convert the answer string to an array:

var array = [0,0,0,0,1]

Solution 1:

Use the Json.parse()function for that.

const answers = "[0,0,0,0,1]"
console.log(JSON.parse(answers))