From bcb5eda7d8454c01bd2cdda1c02e5d6993c1ca67 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 6 Jul 2013 13:47:11 -0700 Subject: [PATCH] Optimize `_.isArguments` and cleanup `_.isArray` and `_.isRegExp`. Former-commit-id: 2ce67cedca1e2b21e206c4822126b86304c8dd5f --- lodash.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index e57917701..0baf9b311 100644 --- a/lodash.js +++ b/lodash.js @@ -1227,12 +1227,12 @@ * // => false */ function isArguments(value) { - return toString.call(value) == argsClass; + return (value && typeof value == 'object') ? toString.call(value) == argsClass : false; } // fallback for browsers that can't detect `arguments` objects by [[Class]] if (!support.argsClass) { isArguments = function(value) { - return value ? hasOwnProperty.call(value, 'callee') : false; + return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false; }; } @@ -1253,7 +1253,7 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return value ? (typeof value == 'object' && toString.call(value) == arrayClass) : false; + return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false; }; /** @@ -2222,7 +2222,7 @@ * // => true */ function isRegExp(value) { - return !!(value && objectTypes[typeof value]) && toString.call(value) == regexpClass; + return (value && objectTypes[typeof value]) ? toString.call(value) == regexpClass : false; } /**