Why is this not working as expected?
The error message indicates that typeof(callback) is undefined.
function A(a, callback)
{
document.write(typeof(callback));
callback();
return a;
}
function Run(func, args)
{
return func.apply(this || window, args || [
function () {
document.write("blah")
}
]);
}
Run(A, [1]);
Interestingly, it works properly when not using function.apply:
function Run2(func, arg)
{
return func(arg,
function () {
document.write("blah")
}
);
}
Run2(A, 1);
I'm still getting familiar with JavaScript, so please bear with me.