encode url javascript

JavaScript
 var uri = "my test.asp?name=ståle&car=saab";
var res = encodeURI(uri); 
Source

Also in JavaScript: