lodash.isFunction vs typeof

JavaScript performance comparison

Test case created by Tim Voronov

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>

<script>
window.fn = function fn() {};
window._isFunction = function() {
    return _.isFunction(this.fn);
};
window._typeof = function() {
    return typeof this.fn === 'function';
};
</script>
    

Preparation code output

<script> window.fn = function fn() {}; window._isFunction = function() { return _.isFunction(this.fn); }; window._typeof = function() { return typeof this.fn === 'function'; }; </script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
_.isFunction
_isFunction()
pending…
typeof
_typeof();
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments