Fastest way to split a string into a multidimensional array of arbitrary dimensions in JavaScript? -
i'm trying determine fastest way split string in javascript multidimensional array arbitary dimensions. there way better looping on string , matching brackets of same depth?
example string:
[1,2,3,[1,2,3,[1,2,3]],4,5,[1,2],[[1,2],[1,2]],[1],[1]]
if don't need count older browsers, can use json.parse:
var = '[1,2,3,[1,2,3,[1,2,3]],4,5,[1,2],[[1,2],[1,2]],[1],[1]]'; var b = json.parse(a);
for older browsers can think of 1 quick , dirty way, use last resort of parsing json.
var = '[1,2,3,[1,2,3,[1,2,3]],4,5,[1,2],[[1,2],[1,2]],[1],[1]]'; var b = (new function('return ' + + ';'))();
Comments
Post a Comment