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

You might want to filter an array in JavaScript by passing the filter criteria and return the filtered array. In...
You can flatten a 2-D array in JavaScript using the concat and apply method as shown in the below code...
Assume that you have an angle in degree and you wish to convert it to radians in JavaScript so that...