EN
JavaScript - get domain name
3
points
In this article, we would like to show you how to get domain name in JavaScript.
Quick solution:
// ONLINE-RUNNER:browser;
const domain = location.hostname;
console.log(domain); // dirask.com
Warning:
locationobject doesn't exist in Node.js.