diff --git a/src/keys.js b/src/keys.js index 36c84bc..7a97c3f 100644 --- a/src/keys.js +++ b/src/keys.js @@ -1,4 +1,5 @@ let ARRAY = Symbol() +let HOLE = Symbol() let OBJECT = Symbol() let REGEXP = Symbol() let DATE = Symbol() @@ -11,7 +12,7 @@ let recurse = obj => { switch (typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj)) { case Array.prototype: array.push(ARRAY, obj.length) - obj.forEach(recurse) + for (let i = 0; i < obj.length; i++) i in obj ? recurse(obj[i]) : array.push(HOLE) break case Object.prototype: temp = [...Object.getOwnPropertyNames(obj).sort(), ...Object.getOwnPropertySymbols(obj)] diff --git a/test.js b/test.js index 2d54ca3..46789ce 100644 --- a/test.js +++ b/test.js @@ -15,6 +15,8 @@ assert.equal(call([]), call([])) assert.equal(call(a), call([0])) } +assert.notEqual(call([1, , 2]), call([1, 2, ,])) // eslint-disable-line no-sparse-arrays + assert.equal(call({}), call({})) {