{"ScriptPreparationCode":"var a = [1,[2,3,[[4,5],[[6]]]],7];\r\nvar flatten1 = function(input, shallow, strict, output) {\r\n output = output || [];\r\n var idx = output.length;\r\n for (var i = 0, length = getLength(input); i \u003C length; i\u002B\u002B) {\r\n var value = input[i];\r\n if (isArrayLike(value) \u0026\u0026 (_.isArray(value) || _.isArguments(value))) {\r\n // Flatten current level of array or arguments object.\r\n if (shallow) {\r\n var j = 0, len = value.length;\r\n while (j \u003C len) output[idx\u002B\u002B] = value[j\u002B\u002B];\r\n } else {\r\n flatten1(value, shallow, strict, output);\r\n idx = output.length;\r\n }\r\n } else if (!strict) {\r\n output[idx\u002B\u002B] = value;\r\n }\r\n }\r\n return output;\r\n};\r\nfunction flatten2(arr, shallow = false) {\r\n return arr.reduce(function (flat, toFlatten) {\r\n return flat.concat(shallow \u0026\u0026 Array.isArray(toFlatten) ? flatten2(toFlatten) : toFlatten);\r\n }, []);\r\n}","TestCases":[{"Name":"flatten1","Code":"flatten1(a);","IsDeferred":false},{"Name":"flatten1 - true","Code":"flatten1(a, true);","IsDeferred":false},{"Name":"flatten2","Code":"flatten2(a);","IsDeferred":false},{"Name":"flatten2 - true","Code":"flatten2(a,true);","IsDeferred":false}]}