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

    1 Comment

  1. April 17, 2023
    Reply

    thanks. I needed to see how to inser a Special Charactert with the code snippet

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

JavaScript supports different types of operators that includes Assignment Operator JavaScript supports different types if Assignment Operators like = +=...
Assume that you have an angle in degree and you wish to convert it to radians in JavaScript so that...
The JavaScript elements and statements are placed within the script tag within the HTML page. You can specify the language...