It depends on what you are going to use the domain name for and specifically whether or not you care about a specified port number. If you URL includes a port number like:
http://stackoverflow.com:80/question/ask
document.location.hostname will return “stackoverflow.com”
while, document.location.host will return “stackoverflow.com:80”
Which is better depends on your use case.
If you happen to be examining the domain name to know whether or not a script will be able to access a script/DOM in another frame/window, then note that the port number is significant. Browsers will not permit cross domain script access across frames/windows. For the purpose of comparing domain names, different port numbers can be considered different domains.