- 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 —— times 方法
语法
_.times(n, iteratee, [context])
times 方法调用 iteratee 函数 n 次。它还将索引传递给 iteratee 函数。请参阅以下示例 −
范例
var _ = require('underscore');
//Example: Check if times method calls a function 3 times
_.times(3, function(index){console.log(index)});
将上述程序保存在 tester.js 中。运行以下命令执行该程序。
命令
\>node tester.js
输出
0 1 2
underscorejs_utilities.htm
广告