Nodejs Number Value Check isNumber()

Here you can find the source of isNumber()

Method Source Code

String.prototype.isNumber = function(){
  var pattern=/^[+\-]?\d+(.\d+)?$/;
  flag=pattern.test(this);/*from  w w  w.  ja  v  a 2 s.  c o  m*/
  if(flag) return true;
  return false;
}

Related

  1. isBetween(min, max, inclusive)
    Number.prototype.isBetween = function (min, max, inclusive) {
      return inclusive
        ? this >= min && this <= max
        : this > min && this < max;
    };
    
  2. isBetweenisBetween(a, b)
    Number.prototype.isBetween = function isBetween(a, b) {
      if(a <= this) {
        return this <= b;
      return this >= b;
    
  3. even()
    Number.prototype.even = function(){
        return (this % 2 === 0);
    };
    
  4. even()
    var puts = require("sys").puts;
    Number.square = function(n) {
      return n * n
    Number.even = function(n) {
      return n % 2 == 0
    Number.odd = function(n) {
      return !this.even(n)
    ...
    
  5. isNumber()
    String.prototype.isNumber = function(){
      return !isNaN(this);
    };
    
  6. isNumber()
    String.prototype.isNumber = function (){
        var str = this;
        return !isNaN(str);
    
  7. isNumber()
    String.prototype.isNumber = function()
      return (/^\d+$/.test(this.Trim()));
    
  8. isNumber()
    String.prototype.isNumber = function()
      try
        var value = this.toString();
        value = value.replace(",","");
          if (parseFloat(value)!= value)
            return false;
          else
    ...
    
  9. isNumeric()
    String.prototype.isNumeric = function(){
        return !isNaN(parseFloat(this)) && isFinite(this);