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" );
Interesting to note. Tried:
And this worked. However, on accident!, there was a space character following the final backslash (all other backslashes were at the end of the line). And this caused an error in the javascript! Removing this space fixed the error, though.
This is in ADT for Android using Cordova.
I tried a number of the above suggestions but got an ILLEGAL character warning in Chrome code inspector. The following worked for me (only tested in Chrome though!)
comes out like...
NOTE the double backslash!!...this seems to be important!
You can just use
That should work
No need of any manual break in code. Just add \n where you want to break.
This will show the alert like
Put the backslash at the end of the line:
Edit I have to note that this is not part of ECMAScript strings as line terminating characters are not allowed at all:
So using string concatenation is the better choice.
Update 2015-01-05 String literals in ECMAScript5 allow the mentioned syntax:
Break up the string into two pieces