Whats the difference between window.location.host and window.location.hostname

Javascript

Javascript Problem Overview


They both seem to give me the same thing (the domain name currently executing the script).

So what's the difference (if any) and where should each be used?

Javascript Solutions


Solution 1 - Javascript

MDN Web Docs - window.location

host....: the host name and port number. [www.google.com]:80
hostname: the host name (without the port number or square brackets). www.google.com

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThomas ClaysonView Question on Stackoverflow
Solution 1 - JavascriptmplungjanView Answer on Stackoverflow