JavaScript Special Characters Example | Practical Demonstration

Some when we have to display the message or text, where we have to place the single quote, double quote and we have display the two pargraph in single message then we always google first javascript special character because some time we forget to recall that small syntax which we have to apply with in the text. In this article we have just answered the thing just to refresh your memories.

JavaScript Special Characters

There are some Special characters like tabs, newlines, quotes and backslashes are mainly used when we have to display paragraphs, text or messages as an output. Below is the way to deal with special characters because it's not possible to directly put the same in any text displayed.

For e.g. Text need to be displayed –

Please attach your Manager's approval email with this request.

For any query please reach out to IT support department. 

By below we can achieve the same:

use \n  for  new line

use \t  for tab

\\  for  backslash

\’  for  single quote

\”  for  double quote

For e.g.

gs.print("Please attach your Manager\'s approval email with this request.\nFor any query please reach out to IT support department");

e.g. of  Client-side Script:

alert("Please attach your Manager\'s approval email with this request.\nFor any query please reach out to IT support department");

JavaScript special character is very small but useful topic. If you have any questions related to same, please feel free to email us or comment below your questions, feedback and suggestions.

Post a Comment

0 Comments