How to cut off string after the first line in the paragraph

var firstLine = theString.split('\n')[0];

Use the optional limit param for increased performance

Tomalak his answer is correct, but in case you want to really only match the first line it will be useful to pass the optional second limit parameter. Like this you prevent that a long string (with thousands of lines) will be splitted till the end before the first match is returned.

With setting the optional limit to 1 we tell the method to return the result as soon as the first match is found with increased performance as a result.

var firstLine = theString.split('\n', 1)[0];

Read more on the limit param for example here in the MDN docs