Javascript Number compareTo(num)

Description

Javascript Number compareTo(num)


Number.prototype.compareTo = function(num) {
  if (typeof num != "number") return false; // if number is not of type number return false

  if (num < this) return 1;
  else if (num > this) return -1;
  else return 0;/*from   www  .  ja v a 2s.c o  m*/
};



PreviousNext

Related