URL.toString()

O método URL.toString() stringifier (en-US) retorna a USVString (en-US) contendo toda a URL. Efetivamente esta é a versão read-only de URL.href.

Note: This feature is available in Web Workers.

Sintaxe

js
const href = url.toString();

Retorna o valor

Exemplos

js
const url = new URL(
  "https://developer.mozilla.org/pt-BR/docs/Web/API/URL/toString",
);
url.toString(); // deve rerornar a URL como string

Especificações

Specification
URL Standard
# URL-stringification-behavior

Compatibilidade de browser

BCD tables only load in the browser

Veja também

  • A interface URL a quem pertence.