encodeURIComponent() — every reserved character is escaped. Best for single values such as query parameter values.
Encoding runs entirely in your browser, so full URLs, tokens, and query strings are never transmitted. URL encoding is a transport formatting step only — it does not encrypt or hide the content of your link.