Utilty to URI-encode strings 3 ways.
Add the method names suggest, these are generally useful when you need to include some string in a URL. Which one is appropriate depends on the situation. Below are some examples of how we find them useful.
escapeis the oldest method, and does the least; we have not had occasion to use it in our apps
encodeURIis generally adequate for strings that will be passed as the values for URL parameters
encodeURIComponentis most thorough encoder, but generally you only need it for strings that will be used as part of a URL domain/path, or if you need to pass a URL as a parameter (we do this frequently in passing API requests to proxies via AJAX)
String to encode: