xxxxxxxxxx
// This should work the same for any language with prefix and postfix increment and decrement.
// Just change the keywords to suit your language.
let array = [0, 1];
// INCREMENT ++
let index = 0;
let prefix_increment = array[++index];
// returns index + 1, array[1] = 1
console.log(prefix_increment); // 1
index = 0;
let postfix_increment = array[index++];
// returns index, then adds 1, array[0] = 0
console.log(postfix_increment); // 0
console.log(index); // 1
// DECREMENT --
index = 1;
let prefix_decrement = array[--index];
// returns index - 1, array[0] = 0
console.log(prefix_decrement); // 0
index = 1;
let postfix_decrement = array[index--];
// returns index, then subtracts 1, array[1] = 1
console.log(postfix_decrement); // 1
console.log(index); // 0
xxxxxxxxxx
++x = x is now 2
x++ = x is now 3 but the showed value remains 2
x = is 3
x = 2 + (2 * 3)
x = 8