On macOS 10.13.1 with Chrome 63 .
I use Object.assignwith the new URL () as the source object, but does it always give an empty object? This seems like weird behavior. Here is my code:
let url = new URL('http://www.yahoo.com');
console.log(url);
let data = Object.assign({}, url);
console.log(data);
Why data is an empty object, while it urlhas a full URL, as shown below:
{
href: "http://www.yahoo.com/",
origin: "http://www.yahoo.com",
protocol: "http:",
username: "",
password: ""
...
}
I also tried:
let data = Object.assign({}, ...url);
but he gives:
Uncaught TypeError: undefined is not a function
source
share