JS interview: Implement map function
- We are using a for loop in myMapFunction which is we are instructing that how to do the work i.e. Imperative way.
The async callback argument can also be used in map function like below:-
Declarative way using Array reduce function
So now we know how the Array map function works. Surely, the declarative way of doing things makes your code less buggy as you don’t need to know how things work under the hood, it’s only you need to tell what needs to be done.
If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇