The optional override for isFunction(object)
in Underscore.js (repo link to definition), reads as follows:
// Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
// IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
var nodelist = root.document && root.document.childNodes;
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
_.isFunction = function(obj) {
return typeof obj == 'function' || false;
};
}
What I'm confused about is the || false
, why is it necessary after a string comparison? Since typeof
always returns a string there should be no ambiguity?
The comment states the override fixes some typeof
bugs, are there cases on the listed platforms when typeof
doesn't return a string?