Is there a character in JavaScript to break up a line of code so that it is read as continuous despite being on a new line?
Something like....
1. alert ( "Please Select file 2. \ to delete" );
Is there a character in JavaScript to break up a line of code so that it is read as continuous despite being on a new line?
Something like....
1. alert ( "Please Select file 2. \ to delete" );
ECMAScript 6 introduces template strings:
For example,
will alert
In your example, you can break the string into two pieces:
Or, when it's a string, as in your case, you can use a backslash as @Gumbo suggested:
Note that this backslash approach is not necessarily preferred, and possibly not universally supported (I had trouble finding hard data on this). It is not in the ECMA 5.1 spec.
When working with other code (not in quotes), line breaks are ignored, and perfectly acceptable. For example: