URL 类


浏览器兼容的 URL 类,根据 WHATWG URL 标准实现。解析URL的示例可以在标准本身里边找到。

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

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.

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.