mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
_.isBoolean should return true for boolean object wrappers.
This commit is contained in:
@@ -318,14 +318,14 @@ $(document).ready(function() {
|
||||
parent.iElement = document.createElement('div');\
|
||||
parent.iArguments = (function(){ return arguments; })(1, 2, 3);\
|
||||
parent.iArray = [1, 2, 3];\
|
||||
parent.iString = 'hello';\
|
||||
parent.iNumber = 100;\
|
||||
parent.iString = new String('hello');\
|
||||
parent.iNumber = new Number(100);\
|
||||
parent.iFunction = (function(){});\
|
||||
parent.iDate = new Date();\
|
||||
parent.iRegExp = /hi/;\
|
||||
parent.iNaN = NaN;\
|
||||
parent.iNull = null;\
|
||||
parent.iBoolean = false;\
|
||||
parent.iBoolean = new Boolean(false);\
|
||||
parent.iUndefined = undefined;\
|
||||
</script>"
|
||||
);
|
||||
|
||||
@@ -614,7 +614,7 @@
|
||||
var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b);
|
||||
if (isNumberA || isNumberB) return isNumberA && isNumberB && +a == +b;
|
||||
// Compare boolean objects by value. The value of `true` is 1; the value of `false` is 0.
|
||||
var isBooleanA = toString.call(a) == '[object Boolean]', isBooleanB = toString.call(b) == '[object Boolean]';
|
||||
var isBooleanA = _.isBoolean(a), isBooleanB = _.isBoolean(b);
|
||||
if (isBooleanA || isBooleanB) return isBooleanA && isBooleanB && +a == +b;
|
||||
// Compare dates by their millisecond values.
|
||||
var isDateA = _.isDate(a), isDateB = _.isDate(b);
|
||||
@@ -738,7 +738,7 @@
|
||||
|
||||
// Is a given value a boolean?
|
||||
_.isBoolean = function(obj) {
|
||||
return obj === true || obj === false;
|
||||
return obj === true || obj === false || typeof obj == 'object' && toString.call(obj) == '[object Boolean]';
|
||||
};
|
||||
|
||||
// Is a given value a date?
|
||||
|
||||
Reference in New Issue
Block a user