Reduce() method Javascript is stupid! cannot use accumulator.push() [SOLVED!]

function uniteUnique(arr) {
            var newArr=[];
            for(index in arguments){
                // i got all args in arr, now i want to sorted the unique
                newArr= newArr.concat(arguments[index]); // concat arguments array save it to newArr
            newArr.unshift([newArr[0]]); // create initial accumulator
            var completeNew= newArr.reduce(function(acc,curVal,curIndex){
                    return acc.concat(curVal); // why i cant use acc.push() method here! but acc.concat works
                    return acc;
            return completeNew;
        uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

In reduce method, why it only works when acc.concat(curVal) but not acc.push(). I also debugged it but cant find any mistake here!. Please help me, sorry for my english, also my messy code. Thanks

.concat() returns a new array, but .push() returns the length of the array.

1 Like

oh now im stupid. Thanks alot for fast reply, and your time. You are really a hero here! thank you! :tada: