We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

DNS

A "domain name" or "hostname" is just one portion of a URL. We'll get to the other parts of a URL later.

For example, the URL https://homestarrunner.com/toons has a hostname of homestarrunner.com. The https:// and /toons portions aren't part of the domain name -> IP address mapping that we've been talking about.

Using the URL API

The URL API is built into JavaScript. You can create a new URL object:

const urlObj = new URL("https://homestarrunner.com/toons");

And then you can extract just the hostname:

const hostname = urlObj.hostname;
console.log(hostname); // homestarrunner.com

Assignment

Complete the getDomainNameFromURL function. Given a full URL, it should return the domain (or host) name.