Test name | Executions per second |
---|---|
regex | 6216.2 Ops/sec |
startWith | 7478.9 Ops/sec |
var foo = ['+++', '---', '===', '@@@', null, undefined, '', 'foo'];
var test = [];
for (var i = 0; i < 1000; i++) {
test = [test, foo];
}
test.map((x) => /^\+\-\=\@/.test(x) ? "'" + x : x);
test.map((x) => {
if (
x?.startsWith('+') ||
x?.startsWith('-') ||
x?.startsWith('=') ||
x?.startsWith('@')
) {
return "'" + x;
}
return x;
});