mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
make toArray return a clone in case of an array
In combination with backbone this makes coll.toArray() return an array instead of just returning coll.models, enabling coll.remove(coll.toArray()) whithout failing half way through.
This commit is contained in:
@@ -278,7 +278,7 @@
|
||||
_.toArray = function(iterable) {
|
||||
if (!iterable) return [];
|
||||
if (iterable.toArray) return iterable.toArray();
|
||||
if (_.isArray(iterable)) return iterable;
|
||||
if (_.isArray(iterable)) return slice.call(iterable);
|
||||
if (_.isArguments(iterable)) return slice.call(iterable);
|
||||
return _.values(iterable);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user