I understand that JavaScript apply() considers the 2nd param as as array param arg for the fn which its being applied to. However in this current code snippet below, item arg is [1,2] instead of [[1,2], 6,7,8,9]
Can someone explain to me as to why this happens?
var orig = [1, 2],
add = [6,7,8,9];
prependArgs.apply(orig, $.merge([orig], add.slice(0)));
function prependArgs(item) {
// item = [1,2] instead of [[1,2], 6,7,8,9] -- Why?
var a = item.slice(0);
for (var i = 0; i < a.length; i++) {
this.unshift(item[i]);
}
}