The console's log function expects this
to refer to the console (internally). Consider this code which replicates your problem:
var x = {};
x.func = function(){
if(this !== x){
throw new TypeError('Illegal invocation');
}
console.log('Hi!');
};
// Works!
x.func();
var y = x.func;
// Throws error
y();
Here is a (silly) example that will work, since it binds this
to console
in your make function:
var make = function(callback,params){
callback.call(console, params);
}
make(console.log,'it will be accepted!');
This will also work
var make = function(callback,params){
callback(params);
}
make(console.log.bind(console),'it will be accepted!');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…