typeof function vs instanceof
JavaScript performance comparison
Info
This testcase compares the performance when checking if a variable (argument) is a function. typeof foo === 'function' vs. foo instanceof Function.
Preparation code
<script>
var foo = function() {};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
typeof |
|
pending… |
instanceof |
|
pending… |
typeof with == |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Andreas Göbel
- Revision 2: published by Andreas Goebel
- Revision 3: published by Gildas
- Revision 4: published
- Revision 5: published
- Revision 6: published
0 comments