Marcus Junius Brutus Marcus Junius Brutus - 1 year ago 84
Javascript Question

assert that an object is an integer number

Using should.js, I am currently doing:;

… is there a more concise way to require that a given object be an integer?

Answer Source

You can use Number.isSafeInteger (to test for 64-bit integers) and Number.isInteger. To use with Should.js:


I generally recommend using Number.isSafeInteger...unless you know you're dealling with potentially really large integer values that have to be stored as floating-point.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download