求教:上面是underscore的一段源碼,讓我比較困惑的是switch的作用,我覺得完全不需要switch啊,直接如果判斷context==null,如果不是直接返回return function () { return func.apply(context, arguments)
}上面這個(gè)不就可以嗎?求各位大神指教?。克淖⑨屩姓f是// Internal function that returns an efficient (for current engines) version
// of the passed-in callback, to be repeatedly applied in other Underscore // functions.請(qǐng)問是對(duì)于比較少參數(shù)的時(shí)候,用call這種方法會(huì)快不少嗎?感覺有別的深意啊,畢竟我不覺得這個(gè)速度會(huì)差很多,可是實(shí)在想不到區(qū)別了
underscore源碼
慕田峪7331174
2018-10-03 09:23:41