URL encoding converts characters into a format that can be transmitted over the Internet. It replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.
Use URL encoding when you need to include special characters in a URL, such as spaces, symbols, or non-ASCII characters. This is common in query parameters and form submissions.
encodeURI is used for complete URLs and doesn't encode characters like /, ?, &, =, etc. encodeURIComponent is used for URL components and encodes these characters as well.