Pass all the values from an array into a function as parameters

前端 未结 4 896
别那么骄傲
别那么骄傲 2021-02-12 20:56

I have an array of values:

[\'a\', \'b\', \'c\', \'d\']

and I need to pass these as parameters to a function:

window.myFunction         


        
4条回答
  •  执念已碎
    2021-02-12 21:24

    Array.prototype.map()

    var arr = ['a','b','c'];
    
    function echo(x){ 
      console.log(x)
    }
    
    function go(){
      arr.map(echo);
    }

提交回复
热议问题