instanceof vs typeof string (v13)

Revision 13 of this benchmark created by Peter on


Test runner

Ready to run.

Testing in
TestOps/sec
typeof
var results = [];
for(var i=0; i<100; ++i){
  results.push(typeof("hello"+i) === "string");
}
ready
instanceof
var results = [];
for(var i=0; i<100; ++i){
  results.push(("hello"+i) instanceof String);
}
ready
constructor
var results = [];
for(var i=0; i<100; ++i){
  results.push(("hello"+i).constructor === String);
}
ready

Revisions

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