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
  • 12,111
  • 21
  • 91
  • 136
Shiva Roy
  • 309
  • 1
  • 2
  • 13

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,314
  • 5
  • 34
  • 63
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
  • 105
  • 3
  • 7
0

this is working

var dataValue="'999999999999"+("000"+(parseInt($(this).attr("data-itemindex").slice( -3 ),10) + 1).toString()).slice(-3)+"'";
Govind Singh
  • 15,282
  • 14
  • 72
  • 106