How i can get the domain name example.com from the set of possible subdomains sub1.example.com sub2.example.com sub3.example.com
example.com
sub1.example.com
sub2.example.com
sub3.example.com
This is faster
const firstDotIndex = subDomain.indexOf('.'); const domain = subDomain.substring(firstDotIndex + 1);