// http://www.example.com/démonstration.html
let url = new URL('http://www.example.com/démonstration.html')
let test = url.toString() === url.href;
console.log('url.href', url.href, 'url.toString()' , url.toString() , 'test' , test);
// url.href http://www.example.com/d%C3%A9monstration.html url.toString() http://www.example.com/d%C3%A9monstration.html test true
https://developer.mozilla.org...
4.URL对象静态方法createObjectURL(object)
URL.createObjectURL(object)是URL 对象的静态方法,用于创建一个DOMString(is a UTF-16 string),其实就是返回了一个在内存中指向传入参数object的引用路径url字符串。 生成的这个url字符串会在当前页面的document被销毁的时候失效。
objectURL = URL.createObjectURL(object);
object
A File, Blob or MediaSource object to create an object URL for.
return
A DOMString containing an object URL that can be used to reference the contents of the specified source object.
window.URL.revokeObjectURL(objectURL);
objectURL
A DOMString representing a object URL that was previously created by calling createObjectURL().
return
ubdefined