Skip to content

Instantly share code, notes, and snippets.

@yyong37
Last active March 7, 2017 12:31
Show Gist options
  • Save yyong37/e9ea253049518c87ca8b to your computer and use it in GitHub Desktop.
Save yyong37/e9ea253049518c87ca8b to your computer and use it in GitHub Desktop.
Javascript
Function.prototype.method = function(name, func) {
if(!this.prototype[name]) {
this.prototype[name] = func;
}
return this;
};
Number.method('integer', function() {
return Math[this < 0 ? 'ceil' : 'floor'](this);
});
document.writeln((-10/3).integer());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment