+ 1

Can someone please explain increments and decrements to me? I only started learning coding yesterday and this is kinda confusing

Increments and Decrements in JavaScript

26th Apr 2017, 8:21 PM
Deanna McLoughlin
4 Answers
+ 3
Increment increases variable's value by "1", decrement decreases by "1". int a = 0 a++ Value of a == 1
26th Apr 2017, 8:32 PM
Alexey
Alexey - avatar
+ 3
@Vaibhav Jadhav In your example in both cases the result is 11. a=10 System.out.println(++a) result 11 a=10 System.out.println(a++) result 10
27th Apr 2017, 5:51 AM
Alexey
Alexey - avatar
+ 1
increment: i++ is the same as i=i+1; decrement: i-- is the same as i=i-1; u increase or decrease your variable by 1
26th Apr 2017, 8:30 PM
M Pax
M Pax - avatar
- 1
suppose a=10 if a++ system.out.println(a); result=10 if ++a system.out.println(a); result=11
27th Apr 2017, 5:33 AM
Vaibhav Jadhav
Vaibhav Jadhav - avatar