Really, pretty much what the title says.
Say you have this string:
var theString = \"a=b=c=d\";
Now, when you run theString
If you want the exact equivalent of the Java implementation (no error checking or guard clauses etc):
function split(str, sep, n) {
var out = [];
while(n--) out.push(str.slice(sep.lastIndex, sep.exec(str).index));
out.push(str.slice(sep.lastIndex));
return out;
}
console.log(split("a=b=c=d", /=/g, 2)); // ['a', 'b', 'c=d']
This has the added benefit of not computing the complete split beforehand, as you mentioned in your question.