my trim script vs google closure compiled version

Benchmark created by Keith on


Test runner

Ready to run.

Testing in
TestOps/sec
My Trim Inclusion
if (!String.prototype["trim"]) {
 String.prototype["trim"] = function() {
  return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
 };
}
ready
Google Closure Compiled Inclusion
String.prototype.trim || (String.prototype.trim = function() {
 return this.replace(/^\s\s*/, "").replace(/\s\s*$/, "")
});
ready

Revisions

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