Marcus Junius Brutus Marcus Junius Brutus - 8 months ago 43
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?


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.