Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment