Returns true if the number is an integer and false if its Number.NaN or a floating point number - Node.js Number

Node.js examples for Number:Int

Description

Returns true if the number is an integer and false if its Number.NaN or a floating point number

Demo Code


/**// w w w.  ja v a2  s  .com
 * Returns true if the number is an integer and false if its Number.NaN or a floating point number
 */
Number.prototype.isInt = function() {
  return parseFloat(this) == parseInt(this, 10) && !isNaN(this);
};

Related Tutorials