Exercice

// Question 1 : Convert the string '[1,2],[3,4]' to the array [[1,2],[3,4]]

// Solution Q1-S1
var s = '[1,2],[3,4]', 
    f = JSON.parse('['+s+']');

// Solution Q1-S2
var s = '[1,2],[3,4]', re = /\[(\d+),(\d+)\],?/g, f = [];
while(a = re.exec(s)) { f.push([+a[1],+a[2]]); }; 
f;

// Question 2 : Convert the string '1,5,8' to the array [[0,1], [1,5], [2,8]]

// Solution Q2-S1:
var s = '1,5,8';
var f = s.split(',').map(function(a,i) { return [i,+a]; })