I did some javascript exercises online (codewars.com). One of the problems asked the user to take an array of array objects and remove one level from the entire array.
[] [] [[1, 2, 3], ["a", "b", "c"], [1, 2, 3]] [1, 2, 3, "a", "b", "c", 1, 2, 3] [[3, 4, 5], [[9, 9, 9]], ["a,b,c"]] [3, 4, 5, [9, 9, 9], "a,b,c"]
I ended up learning about the concat method, but the most popular solution used this operator ...
function (arr){ return [].concat.apply([],arr); }
Can someone explain the use of [] ? I canβt understand how this gives the correct results (and this does not give an explanation on the page). I know that there are many other cases where empty brackets are used as parameters and marking arrays, so understanding the usage here may help me in the future use it in the future.