Some times
strings in your application may span across multiple lines. In this case, we
need to break the string, so that it is completely visible in single page.
There are
two ways to represent multi line strings.
a. Using + operator
b. Using \ symbol
Using + operator
var str1 = "Some times strings in your application may span across multiple lines." + "In this case, we need to break the string, so that it is completely " + "visible in single page.";
Using \ symbol
var str2 = "Some times strings in your application may span across multiple lines. \ In this case, we need to break the string, so that it is completely \ visible in single page.";
string.html
<!DOCTYPE html> <html> <head> <title>strings</title> </head> <body> <script type="text/javascript"> var str1 = "Some times strings in your application may span across multiple lines." + "In this case, we need to break the string, so that it is completely " + "visible in single page."; var str2 = "Some times strings in your application may span across multiple lines. \ In this case, we need to break the string, so that it is completely \ visible in single page."; document.write(str1 + "<br />"); document.write(str2 + "<br />"); </script> </body> </html>
No comments:
Post a Comment