Passing additional parameters in higher-order functions

前端 未结 6 1441
刺人心
刺人心 2020-12-13 11:01

Consider this example:



        
6条回答
  •  孤街浪徒
    2020-12-13 11:44

    With ES6:

    const foos = samples.filter(x => exclude(x, "foos"));
    

    another option would be to use bind(), but I find it difficult to read:

    const foos = samples.filter(exclude.bind(null, "foos"))
    

提交回复
热议问题