From 75a31fffc59af2ad1ab682a63e2aed9669218ac4 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 4 Jan 2010 10:20:46 -0500 Subject: [PATCH] adding boolean coercions to the faster isType methods --- underscore.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/underscore.js b/underscore.js index 31b07a4de..8d9748936 100644 --- a/underscore.js +++ b/underscore.js @@ -483,7 +483,7 @@ // Is a given value an array? _.isArray = function(obj) { - return obj && obj.concat && obj.unshift; + return !!(obj && obj.concat && obj.unshift); }; // Is a given variable an arguments object? @@ -493,12 +493,12 @@ // Is a given value a function? _.isFunction = function(obj) { - return obj && obj.constructor && obj.call && obj.apply; + return !!(obj && obj.constructor && obj.call && obj.apply); }; // Is a given value a string? _.isString = function(obj) { - return obj === '' || (obj && obj.charCodeAt && obj.substr); + return !!(obj === '' || (obj && obj.charCodeAt && obj.substr)); }; // Is a given value a number? @@ -508,12 +508,12 @@ // Is a given value a date? _.isDate = function(obj) { - return obj && obj.getTimezoneOffset && obj.setUTCFullYear; + return !!(obj && obj.getTimezoneOffset && obj.setUTCFullYear); }; // Is the given value a regular expression? _.isRegExp = function(obj) { - return obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false); + return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false)); }; // Is the given value NaN -- this one is interesting. NaN != NaN, and