Skip to content

Instantly share code, notes, and snippets.

@mknln
mknln / gist:7444512
Created November 13, 2013 06:11
Reading JavaScript Patterns I thought of another way to write the decorator pattern. Not yet sure if this has any pitfalls.
SalesOrder.prototype.decorate = function(decorator) {
var override
for (override in decorator) {
if (decorator.hasOwnProperty(override)) {
var oldfunc = this[override]
var decfunc = decorator[override]
var newfunc = function() {
var args = Array.prototype.slice.call(arguments)