that's because actionInt was declared in this line:
var actionInt = parseInt(action);
And you're incrementing this.actionInt++, where this is the call context, determined ad-hoc (probably the object to which you attached the event listener).
I strongly recommend you read up on what this actually references in JS, just like I'd also suggest you specify the radix when using parseInt, and realize that this doesn't make sense:
actionInt = parseInt(action, 10);//action is number?
if (action === 'next')//action is string?
if action is next or previous, parseInt will always return NaN, which, when incremented, still is NaN (Not A Number + 1 is Not A Number)
But which ever way you look at it, I think you're actually looking for a closure:
onPageClick : (function(actionInt)
{
return function(event)
{
var action = event.target.innerHTML;
this.loadPage(actionInt, 25);//what is this?
if (action == "Next"){
console.log(actionInt++);//no this
}
else if (action == "previous"){
console.log(actionInt--);
}
};
}(0)),//pass initial actionInt value here
Refer to this answer on details on how JS resolves expressions/variable names and how closures work...
If actionInt is a global variable, you can omit the IIFE, and just use actionInt, it'll resolve to the global variable by default (or throw an error if it wasn't defined in strict mode)
currentData?console.log(this.actionInt++)orconsole.log(this.actionInt--);will log the same value, right? I mean: the statements are saying: log the current value ofthis.actionInt, then increment/decrement it by one... in other words: ifthis.actionIntis 25, you'll always log 25, then reassign the property to hold either 26 or 24