Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation of Javascript function unescape() [closed]

Tags:

javascript

According to W3 Schools the unescape() JavaScript function has been deprecated. The site states,

"The unescape() function was deprecated in JavaScript version 1.5. Use decodeURI() or decodeURIComponent() instead."

Should I go through and replace all instances of unescape()?

Is the deprecation of JavaScript functions something that web developers concern themselves with and actively update their JavaScript code?

or can I expect that most browsers will support JavaScript 1.5 in the foreseeable future?

like image 960
ConfusedDeer Avatar asked Jan 13 '15 16:01

ConfusedDeer


People also ask

Is Unescape deprecated?

The unescape() function is deprecated. Use decodeURI() or decodeURIComponent() instead.

What does Unescape do in JavaScript?

The unescape() function computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. The escape sequences might be introduced by a function like escape .

What is unescape () and escape () functions?

The escape() function is used to encode a string, making it safe for use in a URL. The unescape() function is used to decode an encoded string.


1 Answers

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape you should update your old scripts:

This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

A Quick Fix?

Fixing it could be as simple as dropping a line into your JS to add in an unescape() method if one doesn't exist.

window.unescape = window.unescape || window.decodeURI;
like image 151
Moob Avatar answered Nov 02 '22 19:11

Moob