Simple ... Just use arr.Flat(n) . Check it now 
\n# Code\n```javascript []\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {Array}\n */\nvar flat = function (arr, n) {\n    return arr.flat(n);\n};\n```
['JavaScript']