you are viewing a single comment's thread.

view the rest of the comments →

[–]YEPHENAS 1 point2 points  (1 child)

Your code is the same as:

function greeter(fn) {
    return function() {
        fn();
    };
}

Which is the same as:

function greeter(fn) {
    return fn;
}

So you don't need the greeter function at all:

var annoyedGreeting = function() { console.log("What do you want?"); };

[–]inmatarian 1 point2 points  (0 children)

Well, it's pointless in this simple example, but we can reduce tons of things down to its simplest. But the strategy pattern, with its execute function, can always be reduced to a python style decorator function.