Wednesday, September 06, 2006

The Decorator Pattern for JavaScript

beppu has written about the Decorator Pattern for Javascript.

He has provided a very very useful piece of code using which every object can now have a before() and after() method that would work like this -

before(‘method’, function() { });
after(‘method’, function() { });

This will provide us more flexibility in playing with objects and definitely reduce the code a little :)

Read more here.