determines whether a positive integer
JavaScript determines whether a string of numbers is a positive integer,
The first thing to understand is these questions
The 1:javascript will automatically block 0 of the number in front of it (I don't know if it's correct to block the word)
Console.log (000000123);//Output 123
The longest positive integer length in the 2:javascript is 21 bits, and more will be counted by scientific notation.
Here is the 21-bit console.log (1111111111111111111111)//Output 1.1111111111111111e+21//Here is 20-bit console.log (111111111111111111111 )//Output 111111111111111110000//after four bit 0 I don't know why, anyway, the 21-bit positive integer number is 0 when the last four digits are displayed.
Having understood these two questions, we can begin to write!
function Ispositiveinteger (s) {//is a positive integer var re =/^[0-9]+[0-9]*[0-9]*$/; return Re.test (s) }
Usage:
Alert (ispositivenum (number))//Returns True -"positive integer;//returns False -" not a positive integer;
JS to determine whether a positive integer is the regular notation of a regular JavaScript positive integer