- Underscore.JS教程
- Underscore.JS - 首頁
- Underscore.JS - 概覽
- Underscore.JS - 環境設定
- Underscore.JS - 迴圈集合
- Underscore.JS - 處理集合
- Underscore.JS - 迴圈陣列
- Underscore.JS - 處理陣列
- Underscore.JS - 函式
- Underscore.JS - 對映物件
- Underscore.JS - 更新物件
- Underscore.JS - 比較物件
- Underscore.JS - 工具
- Underscore.JS - 鏈式操作
- Underscore.JS 實用資源
- Underscore.JS - 快速指南
- Underscore.JS - 實用資源
- Underscore.JS - 討論
Underscore.JS - delay 方法
語法
_.delay(function, wait, *arguments)
delay 方法在等待給定的以毫秒為單位的等待時間後呼叫給定的函式。如果傳遞了引數,那麼引數將傳遞到被呼叫的函式中。請參閱下面的示例
示例
var _ = require('underscore');
var startTimestamp = new Date().getTime();
var add = function(a,b) {
console.log(a + b);
var endTimestamp = new Date().getTime();
console.log(((endTimestamp - startTimestamp)) + ' ms');
};
_.delay(add, 1000, 5, 10);
將上述程式儲存在 tester.js 中。執行以下命令來執行該程式。
命令
\>node tester.js
輸出
15 1028 ms
underscorejs_functions.htm
廣告