- known as post-increment
- it first returns the original value of
ithen increments it by 1
let i = 1, j; j = i++; console.log(i, j); //2 1
First, the value of
i is assigned to
i is incremented by 1. Hence,
i is 2 and
j is 1.
- known as pre-increment
- it first increments the value of
iby 1 then returns it.
let i = 1, j; j = ++i; console.log(i, j); //2 2
first, the value of
i is incremented by 1 and then assigned to
i is 2 and so is
If you found this article helpful, I would be grateful for your support.
"Buy me some paneer curry"
I'd love to read your thoughts on this article!!!