Guest User

Untitled

a guest
Jul 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. Function.prototype.method = function (name, func) {
  2. this.prototype[name] = func;
  3. return this;
  4. };
  5.  
  6. Number.method('integer', function () {
  7. return Math[this < 0 ? 'ceil' : 'floor'](this);
  8. });
  9.  
  10. document.writeln((-10 / 3).integer()); // -3
  11.  
  12. var num = Number('1.2');
  13. alert(num instanceof Number); // true
  14. alert(num instanceof Function); // false
  15. alert(Number instanceof Number); // false
  16. alert(Number instanceof Function); // true
Add Comment
Please, Sign In to add comment