Excecute multiple arrays in one line?

i++ evalutes to i and then increments i up by 1.

So

let i = 0;
console.log(i++);
console.log(i++);
console.log(i);

Will output

0
1
2

To make it increment up by 1 and then evaluate to the old i + 1, use ++i.

There is a good explaination in 30secondsofinterviews.org.

4 Likes