A copy of string with every placeholder replaced by the value variables maps its key to, percent-encoded
where the placeholder is marked with %, and every #-marked placeholder left unfilled and stripped of its
modifier
ReferenceError If variables maps no value to the key of a placeholder to be filled
URIError If a value to be percent-encoded carries an isolated surrogate, which denotes no character and has no UTF-8 representation
Fills the placeholders of a template string.
Replaces every
{key}placeholder with the valuevariablesmaps the key to, leaving the rest of the template as it stands, so that a string written with the shape of its result is completed from values computed elsewhere.A modifier before the opening brace states how a placeholder is filled:
{key}is replaced with the value%{key}is replaced with the URL-encoded value#{key}is preserved as{key}, not replacedURL-encoding percent-encodes every character but the unreserved ones, that is the ASCII letters, the decimal digits and
-._~, so an encoded value is safe at any position of a URL, the query and the fragment included.Keys are made of word characters, that is the ASCII letters, the decimal digits and the underscore; braces enclosing anything else are content and are left as they stand.