diff --git a/lib/cloneDeep.js b/lib/cloneDeep.js index 90a0299..e09e979 100644 --- a/lib/cloneDeep.js +++ b/lib/cloneDeep.js @@ -1,17 +1,15 @@ +var isA = require('./isA'); + module.exports = function cloneDeep(o) { - var newO, - i; + var newO; - if (typeof o !== 'object') { - return o; - } - if (!o) { + if (!o || typeof o !== 'object') { return o; } - if ('[object Array]' === Object.prototype.toString.apply(o)) { + if (isA(o, Array)) { newO = []; - for (i = 0; i < o.length; i += 1) { + for (var i = 0, j = o.length; i < j; i += 1) { newO[i] = cloneDeep(o[i]); } return newO;