Test name | Executions per second |
---|---|
character index | 7038379.0 Ops/sec |
charAt() | 7898072.5 Ops/sec |
slice() | 7452784.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();