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:
xxxxxxxxxx
1
const domain = location.hostname;
2
3
console.log(domain); // dirask.com
Warning:
location
object doesn't exist in Node.js.