How do I break a string across more than one line of code in JavaScript?

0 votes

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" );
Oct 8 in Java-Script by kartik
• 35,820 points
61 views

1 answer to this question.

0 votes

Hello @kartik,

In your example, you can break the string into two pieces:

alert ( "Please Select file"
 + " to delete");

Or, when it's a string, as in your case, you can use a backslash:

alert ( "Please Select file\
 to delete");

Hope it helps!!

Thank YOU!!

answered Oct 8 by Niroj
• 78,120 points

Related Questions In Java-Script

0 votes
1 answer

How do I embed PHP code in JavaScript?

Hello @kartik, If you have individual .js files, and you ...READ MORE

answered Jul 7 in Java-Script by Niroj
• 78,120 points
155 views
0 votes
1 answer

How do I include a JavaScript file in another JavaScript file?

Hello @kartik, It is possible to dynamically generate ...READ MORE

answered Jul 27 in Java-Script by Niroj
• 78,120 points
86 views
0 votes
1 answer

How can I insert a line break into a <Text> component in React Native?

Hello @kartik, This should do it: <Text> Hi~{"\n"} this is a ...READ MORE

answered Sep 20 in Java-Script by Niroj
• 78,120 points
228 views
0 votes
1 answer

How do I add a delay in a JavaScript loop?

Hello @kartik, The setTimeout() function is non-blocking and will return ...READ MORE

answered Sep 20 in Java-Script by Niroj
• 78,120 points
57 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 78,120 points
3,506 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 78,120 points
418 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 78,120 points
287 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 78,120 points
4,204 views
0 votes
1 answer

How do I search for a key of object in javascript?

Use hasOwnProperty(key) for (let i = 0; i ...READ MORE

answered Oct 14 in Java-Script by Niroj
• 78,120 points
52 views
0 votes
1 answer

How do I turn a string to a json in Node.js?

Hello Kartik, Use the JSON function  JSON.parse(theString) ...READ MORE

answered Apr 24 in Java-Script by Niroj
• 78,120 points
104 views