can anyone explain this:

```
x = 4 // x=4
y = x++ // y = 4 and x = 5
why value of y din't increased?
As y is equal to x then y should be 5.
Then why y=4 here?
```

can anyone explain this:

```
x = 4 // x=4
y = x++ // y = 4 and x = 5
why value of y din't increased?
As y is equal to x then y should be 5.
Then why y=4 here?
```

With postfix notation, the value of x is assigned to y and then to value of x is incremented.

With prefix notation, the value of x is incremented and then the value of x is assigned to y.

It ’s not worth your wasting your precious time on this issue, trust me

Not helpful. Understanding how the language works is one of the reasons we’re here.

I would however suggest not using those operators at all if you can help it. Except perhaps in C-style for loops … which you should also avoid if you can help it.

1 Like

You want to avoid situations in JavaScript where this difference matters, but more understanding is more better and this understanding could be useful, especially if @shahab570 ever uses C or C++.

1 Like