Creates an array of values by running each element in `collection` thru `iteratee`. The iteratee is invoked with three arguments: (value, index|key, collection). Many lodash methods are guarded to work as iteratees for methods like `every`, `filter`, `map`, `mapValues`, `reject`, and `some`. The guarded methods are: `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, and `words`
function square(n) {
return n * n
}
map([4, 8], square)
// => [16, 64]
map({ 'a': 4, 'b': 8 }, square)
// => [16, 64] (iteration order is not guaranteed)
| Name | Type | Attribute | Description |
|---|---|---|---|
| collection | The collection to iterate over. | ||
| iteratee | The function invoked per iteration. |
{
"comment": "/**\r\n * Creates an array of values by running each element in `collection` thru\r\n * `iteratee`. The iteratee is invoked with three arguments:\r\n * (value, index|key, collection).\r\n *\r\n * Many lodash methods are guarded to work as iteratees for methods like\r\n * `every`, `filter`, `map`, `mapValues`, `reject`, and `some`.\r\n *\r\n * The guarded methods are:\r\n * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,\r\n * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,\r\n * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,\r\n * `template`, `trim`, `trimEnd`, `trimStart`, and `words`\r\n *\r\n * @since 0.1.0\r\n * @category Collection\r\n * @param {Array|Object} collection The collection to iterate over.\r\n * @param {Function} iteratee The function invoked per iteration.\r\n * @returns {Array} Returns the new mapped array.\r\n * @example\r\n *\r\n * function square(n) {\r\n * return n * n\r\n * }\r\n *\r\n * map([4, 8], square)\r\n * // => [16, 64]\r\n *\r\n * map({ 'a': 4, 'b': 8 }, square)\r\n * // => [16, 64] (iteration order is not guaranteed)\r\n */",
"meta": {
"range": [
1183,
1322
],
"filename": "map.js",
"lineno": 35,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100005797",
"name": "map",
"type": "FunctionDeclaration",
"paramnames": [
"collection",
"iteratee"
]
},
"vars": {
"func": "map~func"
}
},
"description": "Creates an array of values by running each element in `collection` thru\r`iteratee`. The iteratee is invoked with three arguments:\r(value, index|key, collection).\r\rMany lodash methods are guarded to work as iteratees for methods like\r`every`, `filter`, `map`, `mapValues`, `reject`, and `some`.\r\rThe guarded methods are:\r`ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,\r`fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,\r`sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,\r`template`, `trim`, `trimEnd`, `trimStart`, and `words`",
"since": "0.1.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Collection",
"value": "Collection"
}
],
"params": [
{
"type": {
"names": [
"Array",
"Object"
]
},
"description": "The collection to iterate over.",
"name": "collection"
},
{
"type": {
"names": [
"function"
]
},
"description": "The function invoked per iteration.",
"name": "iteratee"
}
],
"returns": [
{
"type": {
"names": [
"Array"
]
},
"description": "Returns the new mapped array."
}
],
"examples": [
"function square(n) {\r return n * n\r}\r\rmap([4, 8], square)\r// => [16, 64]\r\rmap({ 'a': 4, 'b': 8 }, square)\r// => [16, 64] (iteration order is not guaranteed)"
],
"name": "map",
"longname": "map",
"kind": "function",
"scope": "global",
"___id": "T000002R000540",
"___s": true,
"filepath": "map.js"
}