I have a JSON object which contains id and price.
Suppose the maximum length "price" field can hold is of 18 digits.
Now I want to print the id and price but whenever I am printing the price, I'm not getting the actual price value.
Later I came to know that Numbers in JavaScript have limited precision having max size 2**53-1.
I also tried using BigInt because of big size of price field but no luck. like :-
alert(BigInt(data.programs[0].price));
How can I display the price field value correctly?
$(document).ready(function() {
var data = { "programs": [ { "id":100, "price":123456789123456789 }, { "id":200, "price":123456789987654321 } ] };
$.each(data.programs, function (i) {
$.each(data.programs[i], function (key, val) {
alert(key +" : "+ val);
});
});
});