The toString() stringifier method of the Location interface returns a string containing the whole URL. It is a read-only version of Location.href.
toString()None.
A string representing the object's URL.
// Let's imagine this code is executed on https://example.com/path?search#hash
const result = window.location.toString(); // Returns: 'https://example.com/path?search#hash'