Test name | Executions per second |
---|---|
regex | 5412793.0 Ops/sec |
trim | 7305401.0 Ops/sec |
var string = ' fsajdf asdfjosa fjoiawejf oawjfoei jaosdjfsdjfo sfjos 2324234 sdf safjao j o sdlfks dflks l ';
var string2 = ' ';
var string3 = ' a ';
var string4 = ' ';
var pattern = /^\s*$/;
pattern.test(string);
pattern.test(string2);
pattern.test(string3);
pattern.test(string4);
string.trim() === '';
string2.trim() === '';
string3.trim() === '';
string4.trim() === '';