Well, according to the documentation for slice, using a negative index will allow you start indexing from the end of the array rather than the beginning.
So domainParts.slice(domainParts.length - 2, domainParts.length) is equivalent to domainParts.slice(-2).
Another thing is that since admin is a constant, you can add that when you are concatenating the string rather than manipulating the array.
varurl=window.location;// example domain would have a subdomain so https://auth.domain.extvardomain=url.host;varsubdomain='admin';varmainDomain=domain.split('.').slice(-2).join('.');varfullAdminDomain=url.protocol+'//'+subdomain+'.'+mainDomain;
Well, according to the documentation for slice, using a negative index will allow you start indexing from the end of the array rather than the beginning.
So
domainParts.slice(domainParts.length - 2, domainParts.length)is equivalent todomainParts.slice(-2).Another thing is that since admin is a constant, you can add that when you are concatenating the string rather than manipulating the array.
Array.prototype.slice
aww yes! nice!