Marcus Junius Brutus Marcus Junius Brutus - 4 months ago 26
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.