Re:A re-introduction to JavaScript
by tracker1 on Saturday May 09, 2015 @10:56PM
(#9518602)
I find that testing works better when I define my functions separately from binding in objects.
var foo = {
doSomething:(...argv)=doSomethingMethod(foo, argv)
};
return foo;
In this way, the execution is always predictable, as I avoid the use of this altogether... It's my one niggle with koa, that it uses this (execution context) as the request/response context. I tend to it in practice.
It's similar to what Crockford now presents as a preferred approach in dealing with having context for functions... I just like discrete functions that can be tested independently of their execution context... by passing the context as a parameter, this becomes explicit... with binding, the process becomes transparent.
It's similar to what Crockford now presents as a preferred approach in dealing with having context for functions... I just like discrete functions that can be tested independently of their execution context... by passing the context as a parameter, this becomes explicit... with binding, the process becomes transparent.