execution time optimisations for _.isArguments, stricter es3 fallback

This commit is contained in:
Michael Ficarra
2011-10-19 23:53:00 -04:00
parent 221161cecc
commit 42e04ecc7a

View File

@@ -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) {