_.map
Translates all items in an array or object to new array of items.
- // Underscore/Lodash
- var array1 = [1, 2, 3]
- var array2 = _.map(array1, function (value, index) {
- return value * 2
- })
- console.log(array2)
- // output: [2, 4, 6]
- // Native
- var array1 = [1, 2, 3]
- var array2 = array1.map(function (value, index) {
- return value * 2
- })
- console.log(array2)
- // output: [2, 4, 6]
Browser Support for Array.prototype.map()
✔ | ✔ | 1.5 ✔ | 9.0 ✔ | ✔ | ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .