Returns true if str contains a positive integer. - Node.js Number

Node.js examples for Number:Int

Description

Returns true if str contains a positive integer.

Demo Code

function is_positive_int(str) {
  var n = ~~Number(str);
  return String(n) === str && n > 0;
}

Related Tutorials