# 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.

Array we want to flatten

`var arr = [1, [2, 3], [[4]]];`

The output should be

`var arr = [1, 2, 3, 4]`