Created
March 15, 2018 08:12
-
-
Save morrxy/53b8d2a6da7aee6757752788e19b328e to your computer and use it in GitHub Desktop.
[获取host后两位] #javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDomain(host) { | |
var a = host.split('.') | |
var s = a.slice(a.length - 2) | |
return '.' + s.join('.') | |
} | |
getDomain(location.host) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment