Test name | Executions per second |
---|---|
character index | 7203881.5 Ops/sec |
charAt() | 7220289.0 Ops/sec |
slice() | 7037249.0 Ops/sec |
var str = 'foo bar baz';
var noop = Function.prototype;
if (str[0] == 'f') noop();
if (str.charAt(0) == 'f') noop();
if (str.slice(0, 1) == 'f') noop();