From 42e04ecc7a4c7cef44ce42076141c38dacdce6ab Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 19 Oct 2011 23:53:00 -0400 Subject: [PATCH] execution time optimisations for `_.isArguments`, stricter es3 fallback --- underscore.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/underscore.js b/underscore.js index 182070eb3..27b458428 100644 --- a/underscore.js +++ b/underscore.js @@ -739,9 +739,16 @@ }; // Is a given variable an arguments object? - _.isArguments = function(obj) { - return toString.call(obj) == '[object Arguments]' || !!(obj && hasOwnProperty.call(obj, 'callee')); - }; + _.isArguments = toString.call(arguments) == '[object Arguments]' + ? function(obj) { + return toString.call(obj) == '[object Arguments]'; + } + : function(obj) { + return obj + ? hasOwnProperty.call(obj, 'callee') + && hasOwnProperty.call(obj, 'length') + : false; + }; // Is a given value a function? _.isFunction = function(obj) {