Javascript: split string into 2d array

You can use replace to get more compact code:

var months= "2010_1,2010_3,2011_4,2011_7";
var monthArray2d = []

months.replace(/(\d+)_(\d+)/g, function($0, $1, $2) {
    monthArray2d.push([parseInt($1), parseInt($2)]);
})

or map if your target browser supports it:

monthArray2d = months.split(",").map(function(e) {
    return e.split("_").map(Number);
})

Basically, the first function looks for year/month patterns "digits underscore digits", and stores each found substring in an array. Of course, you can use other delimiters instead of underscore. The function doesn't care about the values' delimiter (comma), so that it can be whatever. Example:

var months= "2010/1 ... 2010/3 ... 2011/4";
months.replace(/(\d+)\/(\d+)/g, function($0, $1, $2) {
    monthArray2d.push([parseInt($1), parseInt($2)]);
})

If condensed is what you're after:

var month_array = months.split(",").map(function(x){return x.split("_")});

JavaScript is another dynamic language and its variable type allows you to keep anything wherever you like. You did the split right, now just split that string with _ and put it back in there.

See this example:

var months= "2010_1,2010_3,2011_4,2011_7";

var monthArray = months.split(",");

for (var i = 0; i < monthArray.length; i++) {
   monthArray[i] = monthArray[i].split("_");
}

console.log(monthArray);

I don't know what you mean by not to use monthArray. The code above is the least you can do, probably!