Here you can find the source of concat(value)
/**/*from ww w. j a va 2 s . com*/ * Concatenate two numbers * @param {Number} value Number to concat * @returns {Number} */ Number.prototype.concat = Number.prototype.concat || function (value) { let number = this; // get the number of digits being added let digits = exports.digitLength(value); // add zeros to the end of the number to make room for addition number *= Math.pow(10, digits); // perform the concatenation return number + value; };
Number.prototype.times = function () { var a = []; var i = -1; while (++i < this) { a.push(i); return a; };
Number.prototype.timesPlusOne = function () { return _.map(this.times(), function (i) { return i + 1; }); };
Number.prototype.timesRepeat = function(f){ for(var i=0; i<this; i++){ f();
var x = new Number(2); console.log(x); Number.prototype.timesTwo = function(x){ return x * 2; }; console.log(x.timesTwo(x)); console.log(Number.isNaN(x)); Number.isInteger = Number.isInteger || function(x){ return typeof x === "number" && ...
Number.prototype.clone = function(handler) { return new this.constructor(this); };
Number.prototype.cos = function() { return Math.cos(this);
Number.prototype.countDecimals = function () { if(Math.floor(this.valueOf()) === this.valueOf()) return 0; return this.toString().split(".")[1].length || 0;
Number.prototype.to_s = function(){ return toString(this) } Number.prototype.to_i = function(){ return parseInt(this, 10) } Number.prototype.is_string = function(){return false} Number.prototype.is_hash = function(){return false} Number.prototype.is_array = function(){return false} Number.prototype.is_number = function(){return true} Number.prototype.decimal = function(nb) { if( this.toString().indexOf('.') === false ) return this ; m = Math.pow(10, nb) ; ...
Number.prototype.decimalPlaces = function(digits) { var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)"), m = this.toString().match(re); return m ? parseFloat(m[1]) : this.valueOf(); };