is-natural-number.js
Check if a value is a natural number
Installation
Package managers
npm
npm install is-natural-number
Bower
bower install is-natural-number
Duo
var isNaturalNumber = ;
Standalone
Download the script file directly.
API
isNaturalNumber(number, option)
number: Number
option: Object
Return: Boolean
It returns true
if the first argument is one of the natural numbers. If not, or the argument is not a number, it returns false
.
; //=> true ; //=> false; //=> false; //=> false; //=> false
Check the test for more detailed specifications.
option.includeZero
Type: Boolean
Default: false
By default the number 0
is not regarded as a natural number.
Setting this option true
makes 0
regarded as a natural number.
; //=> false; //=> true
License
Copyright (c) 2014 - 2016 Shinnosuke Watanabe
Licensed under the MIT License.