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