JavaScript — flatten an Array recursively

Flatten a dimensional array is a perfect problem to use recursion.
Recursion is great if you want to solve a big problem by solving smaller instances of that big problem.

Photo by Marc Schulte on Unsplash
var arr = [1, [2, 3], [[4]]];
var arr = [1, 2, 3, 4]