3 ms·
You are free to structure it differently: let x = anotherThing( somethingElse( something() ) );
by pintxo 5y ago
You are free to structure it differently:
let x = anotherThing(
somethingElse(
something()
)
);
- ziml77 5y agoThat's worse because now you have to find the innermost function and then walk back outwards. It gets especially ugly when the calls require other parameters let x = anotherThing( somethingElse( something( x, y, z ), 1, 2, 3 ), "a", "b", "c" ); Or maybe this looks cleaner? let x = anotherThing( somethingElse( something(x, y, z), 1, 2, 3 ), "a", "b", "c" ); Neither is easy to follow.
- pintxo 5y agoI take you are no big fan of Lisp? /s Well, actually I agree with you - sometimes. I have actually written helper functions to get similar pipeline processing capabilities in js. function pipe(...args) { return args.reduce((x, fn) => fn(x), null); } pipe( () => 2, (x) => 7*x, console.log )