Skip to content

Instantly share code, notes, and snippets.

@EpokK
Last active August 29, 2015 14:13
Show Gist options
  • Save EpokK/5ac56e0d73c1ffd62e14 to your computer and use it in GitHub Desktop.
Save EpokK/5ac56e0d73c1ffd62e14 to your computer and use it in GitHub Desktop.
Usefull Vanilla functions
var isMobile = function() {
return !!navigator.userAgent.match(/Android|BlackBerry|BB10; Touch|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
};
Array.prototype.clone = function () {
return Array.prototype.slice.call(this, 0);
};
Array.prototype.clear = function() {
this.length = 0;
return this;
};
// Remove an item of array
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment