函數式編程

1.高階函數:能夠將函數做爲參數或者返回的函數函數

function  a(find, x) {
     return  find(x)
}
function  b(x) {
     return  function (){}
}

2.偏函數:經過指定一個部分參數來產生一個新的定製函數spa

function  isType(type) {
     return  function (obj) {
         return  Object.prototype.toString.call(obj) === `[Object ${type}]`
     }
}
let isFunction = isType( 'Function' )
let isString = isType( 'String' )
  

經過指定了type來產生定製函數,type爲Function即爲判斷是否爲函數的方法,type爲String即爲判斷是否爲String的方法prototype

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息