01Which one should I use?
encodeURIComponent for a single value going inside a URL — a query parameter, a path segment. encodeURI for a whole URL you want to stay usable. The mistake that bites is using encodeURI on one value: an ampersand inside it survives and silently splits your parameter in two.
