URLs can only safely contain a limited set of characters. Spaces, &, ?, #, and non-ASCII letters must be percent-encoded: a space becomes %20, an ampersand %26. In JavaScript, encodeURIComponent() does this for query values.
This matters most in query strings and when building share links. Encode each value, not the whole URL, so you don't accidentally encode the ? and & separators that structure it.