By using special characters {\', \", \\} we can insert the same type of quotes inside and outside the strings.
<body> <div id="myId"></div> <script> var a = 'TechFunda is \'obviously\' good.'; var b = "This flight is \"absolutely\" full."; var c = "TechFunda \\vs\\ DotNetFunda."; document.getElementById("myId").innerHTML = a + "<br />" + b + "<br />" + c; </script> </body>
In the above code snippet we have given the single quote with the special character \' to the variable a
inside the string, double quote with the special character \" to the variable b
inside the string, and backslash with the special character \\ to the variable c
. Every special character in strings can be inserted by escape character( \ ).
OUTPUT
Views: 12719 | Post Order: 63