The unescape function is used in JavaScript to decode a string encoded using the encode function, or to decode other types of encoded strings, such as URLs. For example, the JavaScript below will encode and then decode a string.

var jif = “JavaScript is fun!”; var esc_jif = escape(jif); document.write(esc_jif + “

”); var unesc_jif = unescape(esc_jif); document.write(unesc_jif);

This displays the following results.

JavaScript%20is%20fun%21 JavaScript is fun!

Escape, Function, Programming terms

It should be noted, however, that the escape and unescape functions are not encouraged for future use in JavaScript. Instead, we recommend using the encodeURI or decodeURI functions.