Encode URI API
1. escape()
The escape() function was deprecated in JavaScript version 1.5.
Use encodeURI() or encodeURIComponent() instead.
console.log("Need tips? Visit W3Schools!"); //"Need%20tips%3F%20Visit%20W3Schools%21"
2. encodeURI()
var uri = "my test.asp?name=ståle&car=saab";
var res = encodeURI(uri); //"my%20test.asp?name=st%C3%A5le&car=saab"