Here you can find the source of plus( num )
Number.prototype.plus = function ( num ) { return this + num; }; Number.prototype.minus = function ( num ) { return this - num; }; Number.prototype.multiple = function ( num ) { return this * num; }; Number.prototype.divide = function ( num ) { return this / num; }; Number.prototype.mod = function ( num ) { return this % num; }; var number = 100; var result1 = number.plus(1000); var result2 = number.minus(10); var result3 = number.multiple(3); var result4 = number.divide(4); var result5 = number.mod(2); console.log(result1);// ww w .j a v a2 s. c o m console.log(result2); console.log(result3); console.log(result4); console.log(result5);
Number.prototype.plus = function() { if ((arguments.length == 0) || (arguments.length > 1) || isNaN(arguments[0]))return; return Number(this.toString()) + Number(arguments[0].toString()); }; Number.prototype.minus = function() { if ((arguments.length == 0) || (arguments.length > 1) || isNaN(arguments[0]))return; return Number(this.toString()) - Number(arguments[0].toString()); }; console.log(2); ...
function calcfibonacciNumbers() { var i, nm = []; nm[0] = 0; for(i=1; i<10; i++) { if(i==1) { nm[i] = nm[i-1] + 1; console.log (nm[i]); } else { ...
Number.prototype.plus = function(num) { return this + num }; Number.prototype.minus = function(num) { return this - num }; Number.prototype.multi = function(num) { return this * num debug((5).plus(3).minus(6)) debug((5).multi((3).plus(2))) debug(6..multi(2..plus(2))) function add(x) { return function(y) { return function(z) { return x + y + z debug(add(2) + '\n\n') debug(add(2)(3) + '\n\n') debug(add(2)(3)(5) + '\n\n')
Number.prototype.times = function () { return _.times(this, function (i) { return i; }); };