Is it possible to turn this:
var a = "[0,0,1,1,0,0,1,[1,0,2]]";
into an array so it will work with this?
var newArray = a; // now newArray is [0,0,1,1,0,0,1,[1,0,2]], not "[0,0,1,1,0,0,1,[1,0,2]]"
var a = "[0,0,1,1,0,0,1,[1,0,2]]";
var result = JSON.parse( a );
In addition to JSON.parse you could use eval:
var a = "[0,0,1,1,0,0,1,[1,0,2]]";
var newArray = eval(a);
As for a discussion on whether to use JSON.parse or eval, see this SO discussion: JSON.parse vs. eval()
eval();eval(). Most often it requires rethinking the problem. I'll stand by never.Yes, it is possible, these browsers support JSON.parse(), which will parse a given String and converts it into an object, if the given string is a valid JSON representation.
JSON.parse()?JSON.parse(a)