Underscore.JS - 函式



Underscore.JS 有許多易於使用的方法,可幫助處理函式。本章將詳細介紹它們。

Underscore.JS 提供了處理函式的各種方法,如下所列,-:

序號 方法和語法
1 繫結

_.bind(function, object, *arguments)

2 部分

_.partial(function, *arguments)

3 記憶

_.memoize(function, [hashFunction])

4 延遲

_.delay(function, wait, *arguments)

5 一次

_.once(function)

6 之前

_.before(count, function)

7 包裝

_.wrap(function, wrapper)

8 否定

_.negate(predicate)

9 撰寫

_.compose(*functions)

廣告