Split a string at the first space.
var myString = 'foo bar baz'; var firstWord = myString.substr( 0, myString.indexOf(' ') ); // 'foo' var stringRemainder = myString.substr( myString.indexOf(' ') + 1 ); // 'bar baz'