Why can't direcrlty return a value by using .push() in javascript?

前端 未结 2 1998
梦如初夏
梦如初夏 2021-01-27 11:42

using below flatten function as example, why cant I use return directly on the accumulator. Push()

 function flatten(array){
      return reduce(arr         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 12:14

    The push method returns the new length of the Array.

    MDN documentation for push

    The concat method returns a brand new array containing a combination of the two arrays.

    MDN documentation for concat

提交回复
热议问题