addEventListener using apply()
- by Paul
I'm trying to invoke addEventListener() using apply() method. The code is like:
function rewrite(old){
return function(){
console.log( 'add something to ' + old.name );
old.apply(this, arguments);
}
}
addEventListener=rewrite(addEventListener);
It doesn't work. The code works for normal JavaScript method, for example,
function hello_1(){
console.log("hello world 1!");
}
hello_1=rewrite(hello_1);
Need help!
Thanks!