{}.toString tests

Benchmark created by John-David Dalton on


Preparation HTML

<script>
  var v = 'hello world';
  var toString = {}.toString;
  var type = function(v) {
   return toString.call(v).slice(8, -1).toLowerCase();
  };
  
  var isString = function(v) {
   return type(v) == 'string';
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
simple typeof
toString.call(v) == '[object String]'
ready
simple [[Class]]
toString.call(v) == '[object String]'
ready
abstracted [[Class]]
isString(v);
ready

Revisions

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

  • Revision 1: published by John-David Dalton on