Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View theswedishdev's full-sized avatar
🇺🇦
Slava Ukraini

Joel E. theswedishdev

🇺🇦
Slava Ukraini
View GitHub Profile

Keybase proof

I hereby claim:

  • I am theswedishdev on github.
  • I am joelericsson (https://keybase.io/joelericsson) on keybase.
  • I have a public key ASC9lVKZFc6APiuaeIs-CtyrHUmGr-8kZcSGXoq-e5gfggo

To claim this, I am signing this object:

function loadJS(file) {
let jsElement = document.createElement("script");
jsElement.type = "application/javascript";
jsElement.src = file;
document.body.appendChild(jsElement);
}
@theswedishdev
theswedishdev / Number.js
Last active February 18, 2017 18:01
JavaScript Number methods
Number.prototype.isInteger = function() {
return this % 1 === 0;
};
Number.prototype.isFloat = function() {
return this % 1 !== 0;
};
String.prototype.replaceAll = function(search, replace) {
search = search.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
return this.replace(new RegExp(search, "g"), replace);
};
function getURLparams() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
vars[key] = value;
});
return vars;
}