Permalink
Browse files

Arrays are not guaranteed to have an indexOf method.

  • Loading branch information...
Chad Weider authored and mde committed Aug 26, 2010
1 parent 732ef55 commit 2b81fddbc9e3f01ce719f6fc9fae5cd9e9469f28
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/deps/assert.js
View
@@ -190,17 +190,17 @@ assert._objEquiv = function (a, b) {
return assert._deepEqual(a, b);
}
- var _checkedKeys = [];
+ var _checkedKeys = {};
for (var ka in a) {
- _checkedKeys.push(ka);
+ _checkedKeys[ka] = 1;
if (!assert._deepEqual(a[ka], b[ka])) {
return false;
}
}
for (var kb in b) {
- if (_checkedKeys.indexOf(kb) == -1) {
+ if (!Object.prototype.hasOwnProperty.call(_checkedKeys, kb)) {
return false;
}
}

2 comments on commit 2b81fdd

@aconbere

This comment has been minimized.

Show comment
Hide comment
@aconbere

aconbere Sep 3, 2010

Collaborator

http://github.com/aconbere/assert - contains this patch. I finally got around to putting it on github :)

Collaborator

aconbere replied Sep 3, 2010

http://github.com/aconbere/assert - contains this patch. I finally got around to putting it on github :)

@mde

This comment has been minimized.

Show comment
Hide comment
@mde

mde Sep 3, 2010

Owner

Nice!

Owner

mde replied Sep 3, 2010

Nice!

Please sign in to comment.