Get First Word of String

Benchmark created by Benj Kamm on


Test runner

Ready to run.

Testing in
TestOps/sec
String.prototype.split()
var sentence = "The quick brown fox";
var firstWord = sentence.split(" ")[0];
ready
String.prototype.substr()
var sentence = "The quick brown fox";
var firstWord = sentence.substr(0, sentence.indexOf(" "));
ready

Revisions

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

  • Revision 1: published by Benj Kamm on