扫码一下
查看教程更方便
underscore.js 有许多易于使用的实用方法。 本章将详细讨论它们。
underscore.js 提供了各种实用方法,如下所示
| 序号 | 方法 | 语法 |
|---|---|---|
| 1 | _.identity(value) | |
| 2 | constant | _.constant(value) |
| 3 | _.noop() | |
| 4 | times | _.times(n, iteratee, [context]) |
| 5 | random | _.random(min, max) |
| 6 | mixin | _.mixin(object) |
| 7 | iteratee | _.iteratee(value, [context]) |
| 8 | _.uniqueid([prefix]) | |
| 9 | escape | _.escape(string) |
| 10 | unescape | _.unescape(string) |
| 11 | result | _.result(object, property, [defaultvalue]) |
| 12 | now | _.now() |
| 13 | template | _.template(templatestring, [settings]) |