Skip to content

Commit 0b16f58

Browse files
committed
Merge pull request jashkenas#2259 from debutt/master
Fixes _.isNaN for wrapped numbers
2 parents f8a8bb1 + de6f165 commit 0b16f58

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

test/objects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@
719719
ok(!_.isNaN(void 0), 'undefined is not NaN');
720720
ok(!_.isNaN(null), 'null is not NaN');
721721
ok(!_.isNaN(0), '0 is not NaN');
722+
ok(!_.isNaN(new Number(0)), 'wrapped 0 is not NaN');
722723
ok(_.isNaN(NaN), 'but NaN is');
723724
ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN');
724725
});

underscore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@
13011301

13021302
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
13031303
_.isNaN = function(obj) {
1304-
return _.isNumber(obj) && obj !== +obj;
1304+
return _.isNumber(obj) && isNaN(obj);
13051305
};
13061306

13071307
// Is a given value a boolean?

0 commit comments

Comments
 (0)