Skip to content

Instantly share code, notes, and snippets.

@tiendq
Last active August 19, 2019 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiendq/d71bac8c6ea4943be8ddb2bf52fe7d50 to your computer and use it in GitHub Desktop.
Save tiendq/d71bac8c6ea4943be8ddb2bf52fe7d50 to your computer and use it in GitHub Desktop.
// 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