Skip to content
Advertisement

Tag: functional-programming

Does future in c++ corresponding to promise in javascript?

I am a c++ programmer and tried to study std::future and std::promise these days. When I randomly search some information about future/promise, I found some discussion about future/promise in javascript and promise in javascript has then function. In c++, even though std::future don’t have then function now, but some proposal have mentioned it. So, there are two question: does std::future

How can you reduce(…) the entries of a JavaScript Map object without expanding to a list?

It seems there’s no good standard library way of doing something like this? Uncaught TypeError: thismap.entries(…).reduce is not a function I assume this is due to the entries() function returning an iterator? I don’t want to Array.from(thismap.entries()).reduce(…), as that would unnecessarily build the array in memory. It feels like I’m missing something, but I also don’t want to reimplement something

JavaScript how to build array from nested Object using recursion without mutation

How to make this recursion without mutation, now I am mutating ids array. I want to follow functional programming principles Answer I’d avoid creating a lot of unnecessary intermediate arrays, but to each their own. Making this “immutable” is as easy as returning a new array from the getChildIdRecursively. Also since you are basically duplicating the logic in subscriptionProductsIds you

Advertisement