Following is the answer I am looking at - https://stackoverflow.com/a/45225396/639406
Code -
var result = [].concat.apply([], strs1.map(function(str1) {
return strs2.map(function(str2) {
return str1 + '-' + str2;
});
}));
Most of the thing is clear to me except the use of apply
here. Please let me know what this method is doing here and the first []
parameter to the apply method.
I gone though this - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply but it looks too complicated.