Thursday, January 29, 2026
HomeLanguagesJavascriptUnderscore.js _.unescape() function

Underscore.js _.unescape() function

Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.unescape() function is used to unescape a special character. It works opposite of _.escape() function. It do convert “&” to “&” and so on. 

Syntax:

_.unescape(string);

Parameters: It takes only one parameter i.e the string.

Returns: String is returned by this function.

Note: Some specials files are needed to be included while using this code directly in the browser. It is very necessary to link the underscore CDN before going and using underscore functions in the browser. When linking the underscore.js CDN The “_” is attached to the browser as a global variable.

Some examples are given below for a better understanding of this function.

Example 1:




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let str="<HTML><HEAD></HEAD></HTML>";
      let str2=_.unescape(str)
      console.log(`Original string is: ${str}`)
      console.log(`New string is: ${str2}`)
    </script>
  </body
</html>


Output:

Example 2:




<!DOCTYPE html> 
<html> 
  <head> 
    <script src =  
    </script> 
   </head> 
  <body>
    <script>
      console.log(`& is represented as: ${_.unescape("&")}`)
      console.log(`&#x27; is represented as: ${_.unescape("'")}`)
      console.log(`> is represented as: ${_.unescape(">")}`)
      console.log(`< is represented as: ${_.unescape("<")}`)
    </script>
  </body> 
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32477 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6916 POSTS0 COMMENTS