by ookookook · 12y ago · 0 comments
function doSomething() {
// do stuff
return this;
}
However, the `return this` line doesn't really have anything to do with the core of what the method is supposed to do. Its largely an implementation detail.I feel the method looks much better like :
var doSomething = fluent(function() {
// doSomething
});
The fluent function handles the `return this;` so it doesn't obscure the core method.It is one of most beautiful aspects of javascript that it enables you to build functions from other functions.
No comments yet.