0

alert($(this).attr("data-itemindex")); is giving me '999999999999999003'
and alert(dataValue); is giving 'NaN'

but why?

I am expecting '999999999999999004'

alert($(this).attr("data-itemindex"));
var dataValue = Number($(this).attr("data-itemindex")) + 1;
alert(dataValue);
tshepang
  • 11,360
  • 21
  • 88
  • 132
Shiva Roy
  • 169
  • 1
  • 1
  • 12

3 Answers3

2

Your number is too big. The maximum possible number is:

9 007 199 254 740 992

Have a look at this question.

Community
  • 1
  • 1
damian
  • 5,034
  • 5
  • 31
  • 62
1

if you would like to try this:

https://github.com/rauschma/strint

example of use:

var strint = require("./strint");
strint.add("9007199254740992", "1")
//'9007199254740993'
Hunyo Silaw
  • 95
  • 3
  • 7
0

this is working

var dataValue="'999999999999"+("000"+(parseInt($(this).attr("data-itemindex").slice( -3 ),10) + 1).toString()).slice(-3)+"'";
Govind Singh
  • 14,768
  • 13
  • 67
  • 100