Proxy Pattern & AOP in JavaScript

Proxy Pattern & AOP in JavaScript

To implement a proxy pattern in JavaScript, enabling the basics of aspect-oriented Programming(AOP)

function test(){

  console.log(this,"It is a test.");

}

(function(){

  var toProxy = test;

  test = function(){

    console.log( this, "proxied" ,arguments );

    return toProxy.apply( this );

  };

}

)();
test();

//Window test.html proxied []
//Window test.html It is a test.

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE