The Strategy Pattern is more useful for programming languages that do not support first-class functions. Fortunately, JavaScript treats everything as an object, and allows for run-time object modification. That enables the use of the strategy pattern quite nicely.
Here’s a simple example for changing the behavior of an object without hard-coding the behavior options into the object itself. It allows for flexible changing of object behavior down the road, without having to refactor an entire code block.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=068cf54f-b443-4cae-88a9-874b2315ac09)