DEV Community

Discussion on: Handy JavaScript Tricks Object and Array Tricks to Save You Time

Collapse
 
playwright2poli profile image
playwrightpo

Thanks for the cool article! I'd point out some typos in the host example:

If we run the code, we can see that the first console.log statement logs '#hash'. Then we assigned the value 'example.com' to the url ‘s hash property.

There should be 'example.com' instead of '#hash', and 'newExample.com' instead of 'example.com'.

Collapse
 
aumayeung profile image
John Au-Yeung

Thanks so much for reading and catching that.

I corrected it now. It should be http://example.com/#newHash

Collapse
 
playwright2poli profile image
playwrightpo

It seems we are talking about different sections)). I meant the section describing this code snippet:

const url = new URL('http://example.com/#hash');
console.log(url.host);
url.host = 'newExample.com';
console.log(url.toString());

And the description below this snippet has typos mentioned in my previous comment.

Thread Thread
 
aumayeung profile image
John Au-Yeung

Sorry. I missed that. I corrected it now.