Cast To String (v10)

Revision 10 of this benchmark created on


Setup

function t1(x) {
    return String(x);
  }
  
  function t2(x) {
    return new String(x);
  }
  
  function t3(x) {
    return x + '';
  }
  
  function t4(x) {
    return x.toString();
  }
  
  function t5(x) {
    return '' + x;
  }
  var o = {
    toString: function() {
      return "87";
    }
  };

Test runner

Ready to run.

Testing in
TestOps/sec
String Function
t1(87)
ready
String Constructor
t2(87)
ready
Concatenate Empty String
t3(87)
ready
toString Method
t4(87)
ready
Concatenate Empty String at start
t5(87)
ready
Concate Empty String & toString Method
t3(o)
ready

Revisions

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