JavaScript Tips

Buy this website for $5000 USD

Priced to sell, this is an established JavaScript website, growing in popularity as evidenced by its Alex ranking. Includes most website content. The price is NON-NEGOTIABLE. Serious buyers should contact

Extending a String Across Multiple Lines

In JavaScript, String Literals start and end with a quote character. String Literals cannot span multiple lines unless an escape character \ is placed at the end of each line that does not contain the ending quote character. For example, this isn't valid syntax:

var stringVar = "I am a string that
extends
beyond a single line";

The string below is valid because the escape character is appended to the end of each line of the String Literal that doesn't receive the final quote.

var stringVar = "I am a string that \
extends \
beyond a single line";

Note that had we wanted the string to appear with line terminators as it does in the source code, we would need to replace the white space characters preceding the escape characters with line feeds characters like this:

var stringVar = "I am a string that\n\
extends\n\
beyond a single line";