Skip to content

Instantly share code, notes, and snippets.

@zbigniewTomczak
Created February 19, 2013 13:45
Show Gist options
  • Save zbigniewTomczak/4986023 to your computer and use it in GitHub Desktop.
Save zbigniewTomczak/4986023 to your computer and use it in GitHub Desktop.
Function.prototype.method = function (name, func) {
this.prototype[name]=func;
return this;
};
Number.method('integer', function() {return Math[this < 0 ? 'ceil' : 'floor'](this);});
console.log((-10/3).integer());
String.method('trim', function() {return this.replace(/^\s+|\s+$/g, '');});
console.log(" sdf ".trim());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment