My code has an array of elements as follows:
element: { fromX: { id: ... } , toX: { id: ... } }
Requirement is to pull all the fromX ids into one array, and all toX ids into other.
There are a couple of different ways,
such as using foreach, reduce, iterating for each respectively, but I'm searching for an optimal functional way to return two arrays with one mapping?
fromXandfromYvalues are shown?[froms, tos] = transpose(elements.map(e => [e.fromX, e.toX]))is the functional way - unfortunately there is no nativetransposefunction in JS