From 4d69a0ce2960647fb7852ae35e885c08effa2980 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Nov 2014 00:02:00 -0800 Subject: [PATCH] Add comments to `_.isFunction`. [ci skip] --- lodash.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 948fd1ed3..7d7b968c1 100644 --- a/lodash.js +++ b/lodash.js @@ -7377,9 +7377,13 @@ // https://github.com/jashkenas/underscore/issues/1621 return typeof value == 'function' || false; } - // fallback for older versions of Chrome and Safari + // fallback for environments that return incorrect `typeof` operator results if (isFunction(/x/) || !Uint8Array || !isFunction(Uint8Array)) { isFunction = function(value) { + // the use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for + // regexes and modern Safari which returns 'object' for typed array + // constructors return toString.call(value) == funcClass; }; }