This question may help: How to pass variable by reference in javascript? Read data from ActiveX function which returns more than one value
To summarise, Javascript primitive types are always passed by value, whereas the values inside objects are passed by reference (thanks to commenters for pointing out my oversight). So to get round this, you have to put your integer inside an object:
var myobj = {x:0};_x000D_
_x000D_
function a(obj)_x000D_
{_x000D_
obj.x++;_x000D_
}_x000D_
_x000D_
a(myobj);_x000D_
alert(myobj.x); // returns 1_x000D_
_x000D_
_x000D_