Wednesday, 22 August 2018

JavaScript: Working with multi line strings

By using \ (backslash), we can handle multi line strings in Javascript.

multi.html
<!DOCTYPE html>

<html>
 <head>
  <title>Multi line</title>
 </head>
 
 <body>
  <script type="text/javascript">
   var str = "Hello PTR, \
   How are you. \
   How is life going on!!!!!!";
   
   document.write(str);
  </script>
 </body>
</html>



Previous                                                 Next                                                 Home

No comments:

Post a Comment