类:URL
¥Class: URL
浏览器兼容的 URL
类,按照 WHATWG 网址标准实现。已解析 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
对象的所有属性都被实现为类原型上的获取器和设置器,而不是对象本身的数据属性。因此,与 旧版 urlObject
不同,在 URL
对象(例如 delete myURL.protocol
、delete myURL.pathname
等)的任何属性上使用 delete
关键字没有效果,但仍会返回 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 urlObject
s,
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
.