Another way to do it would be mapping over it and taking only the properties we'd like to keep instead of deleting the ones we don't want, which has the advantage of not caring if in the future the object changes and has more properties.
+1 to this approach. When the anticipated result is a same length array with derived data map() is the best fit; and extracting desired properties is a safer approach than mutating the source object.
I personally like reduce(), but would only use it when both filtering and deriving data.
Another way to do it would be mapping over it and taking only the properties we'd like to keep instead of deleting the ones we don't want, which has the advantage of not caring if in the future the object changes and has more properties.
+1 to this approach. When the anticipated result is a same length array with derived data
map()
is the best fit; and extracting desired properties is a safer approach than mutating the source object.I personally like
reduce()
, but would only use it when both filtering and deriving data.Hey SavagePixie. Thanks for sharing. Sure will try this approach in near future.