addEventListener using apply()

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-05-23T08:31:28Z Indexed on 2010/05/23 8:40 UTC
Read the original article Hit count: 170

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about apply