I have a string value \' 9223372036854775807 \'. I use Number() function in JavaScript to convert it to a number value using the following Code
var numericVa
The problem why Number('9223372036854775807') produce 9223372036854776000 is that JavaScript have limited precision (up to 16 digits) and you need 19 digits.
One of solutions might be using of java script big-numbers library:
// Initializa library:
var bn = new BigNumbers();
// Create numbers to compare:
var baseNumber = bn.of('9223372036854775807');
var toCompareNumber = bn.of('9223372036854775808');
// Compare:
if(baseNumber.lessOrEquals(toCompareNumber)) {
console.log('This should be logged');
} else {
console.log('This should NOT be logged');
}