probleme with auto increamentation (++, +=) Operators

hi am trying make a easy way to auto increase a variable .


in this example, so 


when i showPicture , the var PID and defxy[1] need to increase after show.
Is work good for ++, but not the +=


function ActionKey(WhatToDo) {
var PID = 83; // default PID for actionkey huds
var defxy = [1200,500]; // default x y pos for actionkey
var PH = 125; // picture fixed heigth from Action-Key.png
if (WhatToDo==='show') {
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
}
}






The way clearer.
Why does this return me 5, 6 and not 5, 5  ?


var A = 5;
var B = 5;
console.log((A++)+ ' ' + (B+=1)); // return 5 6




That fµ©£ me, all the easy way, with which I would like make my code.
Is there a way? or is a buggy javascript ?
http://stackoverflow.com/questions/26031404/what-does-x-in-javascript-do


That said, I recommend not creating such convoluted lines. Split them up into more lines where the actions are clearer. Easier to read, easier to debug.
The way clearer.
Why does this return me 5, 6 and not 5, 5  ?



var A = 5;
var B = 5;
console
.log((A++)+ ' ' + (B+=1)); // return 5 6



It returns 5,6 instead of 5,5 because += sets it to 6 before the return call..


++ adds but returns the original value


+= adds and returns the new value


if showing it similar to a code makes more sense

Code:
// var ++ works like this

var A = 5
var A_original = A
A = A + 1
return A_original

// var += value works like this

var A = 5
A = A + value
return A
exist somes ways to syntaxe ++ returns the original value , but with a variable ?


example:

Code:
A = 5;
B = 5;

Console.log( (A++B) ); // example return 5
Console.log( (A++B) ); // example return 10
Console.log( (A) ); // example return 15
IDK if that's possible, but why not just make it such that your variables are


var PH = 125;
var defxy = [1200,500-PH];



so that your first defxy[1] += line will return 500 which is the first value that you want to use
@Engr. Adiktuzmiko


The complete code is a little more laborious.
I had purified it for my question.


But thank you, I think that answers my question.
we cannot
I will do as I usually do.


EDIT: HAHA ok '  why not just make it such that your variables '


ok is true, Thank you I was tired
I'm not sure if you really cant, and I can't test so I just gave the most plausible answer that I can think of.


You can still test A++B in case it might actually be doable


now if you can't do my suggestion of still using += with your original variable reduced by the first increment (but IDK of a situation where that cannot be done so far), then you could just do


if (WhatToDo==='show') {
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1], 100, 100, 255, 0);
defxy[1]+=PH;
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1], 100, 100, 255, 0);
defxy[1]+=PH;
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1], 100, 100, 255, 0);
defxy[1]+=PH;
}




EDIT : so you can do the 500-PH edit?
I


EDIT : so you can do the 500-PH edit?



Yes i test and it worked impeccably it was the way I wanted to build my code.
It suffisait d'y thought, I don't regret my question you helped.
Thank you.


Example: for auto incrementation


function ActionKey(WhatToDo) {
var PID = 83; // default PID for actionkey huds
var PH = 125; // picture fixed heigth from Action-Key.png
var defxy = [1200,500-PH]; // default x y pos for actionkey

if (WhatToDo==='show') {
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
$gameScreen.showPicture(PID++, 'Action-Key', 0, defxy[0], defxy[1]+=PH, 100, 100, 255, 0);
}
}


@  

Original thread: https://forums.rpgmakerweb.com/threads/probleme-with-auto-increamentation-operators.73224/