类:URL


【Class: URL

浏览器兼容的 URL 类,按照 WHATWG URL 标准实现。解析后的 URL 示例 可在标准本身中找到。 URL 类也可以在全局对象上使用。

【Browser-compatible URL class, implemented by following the WHATWG URL Standard. Examples of parsed URLs may be found in the Standard itself. The URL class is also available on the global object.】

根据浏览器的约定,URL 对象的所有属性都作为类原型上的 getter 和 setter 实现,而不是作为对象本身的数据属性。因此,与 遗留 urlObjects 不同,对 URL 对象的任何属性使用 delete 关键字(例如 delete myURL.protocoldelete myURL.pathname 等)不会产生任何效果,但仍然会返回 true

【In accordance with browser conventions, all properties of URL objects are implemented as getters and setters on the class prototype, rather than as data properties on the object itself. Thus, unlike legacy urlObjects, using the delete keyword on any properties of URL objects (e.g. delete myURL.protocol, delete myURL.pathname, etc) has no effect but will still return true.】