Last active
August 19, 2019 08:33
-
-
Save tiendq/d71bac8c6ea4943be8ddb2bf52fe7d50 to your computer and use it in GitHub Desktop.
This file contains 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
// https://davidwalsh.name/essential-javascript-functions | |
let getAbsoluteUrl = (function () { | |
let a; | |
return function (url) { | |
if (!a) | |
a = document.createElement('a'); | |
a.href = url; | |
return a.href; | |
}; | |
})(); | |
// Usage | |
getAbsoluteUrl('/something'); // https://davidwalsh.name/something |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment