Insert special character into a string in JavaScript

If you want to insert a special character into a string in JavaScript , you can use he escape sequences to do it.

For example , if you want to insert the copyright symbol into a string in JavaScript , you can use the \u00A9 escape sequence as shown below.

How to Insert Special Character in to a string in JavaScript ?

<script>
    var input = "This page is \u00A9 Senthil Kumar";
    document.write(input);     
</script>

The backslash character defines the escape character in JavaScript and in the above code snippet (u00A9) we are using the unicode sequence which is a kind of pattern for a specific character where \u00A9 represents the copyright symbol.

image

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.