1 # is-number [![NPM version](https://img.shields.io/npm/v/is-number.svg?style=flat)](https://www.npmjs.com/package/is-number) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![NPM total downloads](https://img.shields.io/npm/dt/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-number.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-number)
3 > Returns true if the value is a number. comprehensive tests.
5 Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
9 Install with [npm](https://www.npmjs.com/):
12 $ npm install --save is-number
17 To understand some of the rationale behind the decisions made in this library (and to learn about some oddities of number evaluation in JavaScript), [see this gist](https://gist.github.com/jonschlinkert/e30c70c713da325d0e81).
20 var isNumber = require('is-number');
25 See the [tests](./test.js) for more examples.
28 isNumber(5e3) //=> 'true'
29 isNumber(0xff) //=> 'true'
30 isNumber(-1.1) //=> 'true'
31 isNumber(0) //=> 'true'
32 isNumber(1) //=> 'true'
33 isNumber(1.1) //=> 'true'
34 isNumber(10) //=> 'true'
35 isNumber(10.10) //=> 'true'
36 isNumber(100) //=> 'true'
37 isNumber('-1.1') //=> 'true'
38 isNumber('0') //=> 'true'
39 isNumber('012') //=> 'true'
40 isNumber('0xff') //=> 'true'
41 isNumber('1') //=> 'true'
42 isNumber('1.1') //=> 'true'
43 isNumber('10') //=> 'true'
44 isNumber('10.10') //=> 'true'
45 isNumber('100') //=> 'true'
46 isNumber('5e3') //=> 'true'
47 isNumber(parseInt('012')) //=> 'true'
48 isNumber(parseFloat('012')) //=> 'true'
53 See the [tests](./test.js) for more examples.
56 isNumber('foo') //=> 'false'
57 isNumber([1]) //=> 'false'
58 isNumber([]) //=> 'false'
59 isNumber(function () {}) //=> 'false'
60 isNumber(Infinity) //=> 'false'
61 isNumber(NaN) //=> 'false'
62 isNumber(new Array('abc')) //=> 'false'
63 isNumber(new Array(2)) //=> 'false'
64 isNumber(new Buffer('abc')) //=> 'false'
65 isNumber(null) //=> 'false'
66 isNumber(undefined) //=> 'false'
67 isNumber({abc: 'abc'}) //=> 'false'
73 <summary><strong>Contributing</strong></summary>
75 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
80 <summary><strong>Running Tests</strong></summary>
82 Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
85 $ npm install && npm test
91 <summary><strong>Building docs</strong></summary>
93 _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
95 To generate the readme, run the following command:
98 $ npm install -g verbose/verb#dev verb-generate-readme && verb
105 You might also be interested in these projects:
107 * [even](https://www.npmjs.com/package/even): Get the even numbered items from an array. | [homepage](https://github.com/jonschlinkert/even "Get the even numbered items from an array.")
108 * [is-even](https://www.npmjs.com/package/is-even): Return true if the given number is even. | [homepage](https://github.com/jonschlinkert/is-even "Return true if the given number is even.")
109 * [is-odd](https://www.npmjs.com/package/is-odd): Returns true if the given number is odd. | [homepage](https://github.com/jonschlinkert/is-odd "Returns true if the given number is odd.")
110 * [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
111 * [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
112 * [odd](https://www.npmjs.com/package/odd): Get the odd numbered items from an array. | [homepage](https://github.com/jonschlinkert/odd "Get the odd numbered items from an array.")
116 | **Commits** | **Contributor** |
118 | 38 | [jonschlinkert](https://github.com/jonschlinkert) |
119 | 5 | [charlike](https://github.com/charlike) |
125 * [github/jonschlinkert](https://github.com/jonschlinkert)
126 * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
130 Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
131 Released under the [MIT License](LICENSE).
135 _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 17, 2017._