mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
fixes #347
This commit is contained in:
@@ -66,6 +66,10 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
clone.lucky.push(101);
|
clone.lucky.push(101);
|
||||||
equals(_.last(moe.lucky), 101, 'changes to deep attributes are shared with the original');
|
equals(_.last(moe.lucky), 101, 'changes to deep attributes are shared with the original');
|
||||||
|
|
||||||
|
equals(_.clone(undefined), void 0, 'non objects should not be changed by clone');
|
||||||
|
equals(_.clone(1), 1, 'non objects should not be changed by clone');
|
||||||
|
equals(_.clone(null), null, 'non objects should not be changed by clone');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("objects: isEqual", function() {
|
test("objects: isEqual", function() {
|
||||||
|
|||||||
@@ -645,6 +645,7 @@
|
|||||||
|
|
||||||
// Create a (shallow-cloned) duplicate of an object.
|
// Create a (shallow-cloned) duplicate of an object.
|
||||||
_.clone = function(obj) {
|
_.clone = function(obj) {
|
||||||
|
if (!_.isObject(obj)) return obj;
|
||||||
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
|
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user