Tutorialspoint.dev

JavaScript | escape()

The escape() function takes a string as a parameter and encodes it so that it can be transmitted to any computer in any network which supports ASCII characters.

Syntax :

escape(string)

Note : This function only encodes the special characters.
Exceptions : @ – + . / * _

<script>
  
// Special character encoded with
// escape function
document.write(escape("Geeks for Geeks!!!"));
  
document.write("<br>");
  
// Print encoded string using escape() function
// Also include exceptions i.e. @ and .
document.write(escape("To contribute articles contact us at" +
                       "[email protected]"));
</script>                    

Output :

Geeks%20for%20Geeks%21%21%21
To%20contribute%20articles%20contact%20us%[email protected] 


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter