* Converts the `collection` to an array. * * @static * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to convert. * @returns {Array} Returns the new converted array. * @example * * (function() { return _.toArr
(collection)
| 39194 | * // => [2, 3, 4] |
| 39195 | */ |
| 39196 | function toArray(collection) { |
| 39197 | if (collection && typeof collection.length == 'number') { |
| 39198 | return slice(collection); |
| 39199 | } |
| 39200 | return values(collection); |
| 39201 | } |
| 39202 | |
| 39203 | /** |
| 39204 | * Performs a deep comparison of each element in a `collection` to the given |