In JavaScript, there would be a slight performance hit if you used reduce to perform a map operation because of returning an array each time. However, immutable data structures in other languages (like Clojure's vector) would not really see a performance hit because of how they are stored. You've given me an idea on a follow up post to discuss immutability and lazy vs. eager evaluation. Thanks for the feedback!
Using reduce instead of map won't be returning a new array on each iteration? Therefore lesser performance?
In JavaScript, there would be a slight performance hit if you used
reduceto perform amapoperation because of returning an array each time. However, immutable data structures in other languages (like Clojure'svector) would not really see a performance hit because of how they are stored. You've given me an idea on a follow up post to discuss immutability and lazy vs. eager evaluation. Thanks for the feedback!Thank you!