mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +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.iElement = document.createElement('div');\
|
||||||
parent.iArguments = (function(){ return arguments; })(1, 2, 3);\
|
parent.iArguments = (function(){ return arguments; })(1, 2, 3);\
|
||||||
parent.iArray = [1, 2, 3];\
|
parent.iArray = [1, 2, 3];\
|
||||||
parent.iString = 'hello';\
|
parent.iString = new String('hello');\
|
||||||
parent.iNumber = 100;\
|
parent.iNumber = new Number(100);\
|
||||||
parent.iFunction = (function(){});\
|
parent.iFunction = (function(){});\
|
||||||
parent.iDate = new Date();\
|
parent.iDate = new Date();\
|
||||||
parent.iRegExp = /hi/;\
|
parent.iRegExp = /hi/;\
|
||||||
parent.iNaN = NaN;\
|
parent.iNaN = NaN;\
|
||||||
parent.iNull = null;\
|
parent.iNull = null;\
|
||||||
parent.iBoolean = false;\
|
parent.iBoolean = new Boolean(false);\
|
||||||
parent.iUndefined = undefined;\
|
parent.iUndefined = undefined;\
|
||||||
</script>"
|
</script>"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -614,7 +614,7 @@
|
|||||||
var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b);
|
var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b);
|
||||||
if (isNumberA || isNumberB) return isNumberA && isNumberB && +a == +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.
|
// 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;
|
if (isBooleanA || isBooleanB) return isBooleanA && isBooleanB && +a == +b;
|
||||||
// Compare dates by their millisecond values.
|
// Compare dates by their millisecond values.
|
||||||
var isDateA = _.isDate(a), isDateB = _.isDate(b);
|
var isDateA = _.isDate(a), isDateB = _.isDate(b);
|
||||||
@@ -738,7 +738,7 @@
|
|||||||
|
|
||||||
// Is a given value a boolean?
|
// Is a given value a boolean?
|
||||||
_.isBoolean = function(obj) {
|
_.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?
|
// Is a given value a date?
|
||||||
|
|||||||
Reference in New Issue
Block a user