Closed lcnvdl closed 10 years ago
I'm testing the performance of iio.isFunction in different browsers.
http://jsperf.com/isfunction-performance/2
Tests:
isFunction1 = function(fn) { return toString.call(fn) === "[object Function]"; } isFunction2 = function(fn) { return typeof(fn) === "function"; } isFunction3 = function(fn) { return (fn instanceof Function); } // iio.isFunction isFunction4 = function(fn) { var getType = {}; return fn && getType.toString.call(fn) === '[object Function]'; }
Results:
Chrome 35.0.1916
Firefox 31.0
IE 10.0
My recomendation
iio.isFunction = function (fn) { return typeof fn === 'function'; }
Interesting, I wonder where I found that one.. Thanks for the recommendation, the optimal function has been integrated in 1.3 and added to 1.2
I'm testing the performance of iio.isFunction in different browsers.
http://jsperf.com/isfunction-performance/2
Tests:
Results:
Chrome 35.0.1916
Firefox 31.0
IE 10.0
My recomendation