+ 1
Why doesn't x=a++ increment a expected number?
/*Hello World! Why doesn't the piece of code below output 11 even though it's incremented in the x variable.*/ var a=10; var x; x=(a++); document.write(x);
4 Réponses
+ 4
Two types of increment operator:
1. Pre increment: ++var ( increments immediately )
2. Post increment: var++ ( increment will be reflected after the current expression/statement/line )
If you don't know about these things, you need to complete your lesson first.
+ 2
value of a will be increased after the statement x=a++;
That is why it's called post increment
+ 1
⚙️mega ☄️ could you broaden what is post increment
Thanks
+ 1
⚙️mega ☄️ The code snippet here was taken from a comment so I got curious as well as confused about it.
Thanks btw
Now I must go and complete my lesson