What is a JavaScript Escape Characters ?

 Posted by Akiii on 10/30/2012 | Category: JavaScript Interview questions | Views: 1878 | Points: 40
Answer:

In JavaScript, the backslash (\) is an escape character.

<script type="text/javascript">

<!--
document.write("The "escape" character");
//-->
</script>


As soon as the browser encounters the first double quote, it will think that the string has finished. Further, it will result in an error because it will be expecting the closing bracket.

<script type="text/javascript">

<!--
document.write("The \"escape\" character");
//-->
</script>



Thanks and Regards
Akiii


Source: quackit | | Alert Moderator 

Comments or Responses

Login to post response