JavaScript location.host vs location.hostname example for this domain address http://jquery4u.com

location.host gives us jquery4u.com
location.hostname gives us jquery4u.com

You may be wondering, whats the difference?

Well host takes into consideration any specific ports also!

ports

Try it below!

Check out this awesome site below.

source:
http://bl.ocks.org/abernier/raw/3070589/

Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.


No Reader comments

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.