How can I pre-set arguments in JavaScript function call? (Partial Function Application)

前端 未结 7 1624
时光取名叫无心
时光取名叫无心 2020-11-27 11:25

I am trying to write a JavaScript function that will return its first argument(function) with all the rest of its arguments as preset parameters to that function.

So

相关标签:
7条回答
  • 2020-11-27 12:01

    Easy way to achieve presetting of parameters without calling the function straight away (when e.g. awaiting user confirmation), is to "dress" the function in another anonymous function.

    Instead of: exportFile(docType)

    Do: function(){ return exportFile(docType) }

    0 讨论(0)
提交回复
热议问题