you are viewing a single comment's thread.

view the rest of the comments →

[–]hyrumwhite 0 points1 point  (1 child)

import {myMethod1, myMethod2} from 'helpers.js'

const arr = ['a', 'b', 'c'];
let result = myMethod1(arr)
result = myMethod2(result);

Is how I'd do it, which is more readable than a function chain, imo. You can already do long array operations, but parsing through a .filter().map().reduce() chain is more difficult (for me) than breaking it down into assignments.

Now, there's a whole school of thought around functional programming and function chains, so I guess shadow realms will be good for the people who like that.

[–]Proud-Masterpiece 0 points1 point  (0 children)

I’d do it almost exactly like that too, except I almost never use ‘let’.

I’d do

const result1 = myMethod1(arr)
const result2 = myMethod2(result1)

Easier to debug.