Advertisement
728x90
encodeURI() function is used to encode an URL. This function requires a URL string as a parameter and return that encoded string.
decodeURI() function is used to decode an URL. This function requires an encoded URL string as parameter and return that decoded string.
Note: If you want to encode characters such as / ? : @ & = + $ # then you need to use encodeURIComponent().
javascript
1let uri = "employeeDetails?name=john&occupation=manager";
2
3let encoded_uri = encodeURI(uri);
4
5let decoded_uri = decodeURI(encoded_uri);Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 26
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
24of476