+ 4
How do you add in a different order other than i++ ?
I’m a Rookie to JavaScript and I’m really interested to know how do u add number in, 2’s and 3’s and 4’s or any other synonymous way other than i++! I hope someone will come with a great example along with explanation ! Thanks in advance 😁
4 Answers
+ 17
i++ is the same as i+=1 and i=i+1
There is no other way to add 2 to i except i+=2 or i=i+2
+ 5
Thanks a lot @Swapnil!
I thought it would be more complicated but never realised it would be this easy 😅🙌🏻🙏
+ 4
Yea I’m getting a catch on to it now! Thanks man @ashish kumar
+ 2
++i and i++ are same when initialsed to a variable. Any of both can be used, only difference being in '++i' the value is incremented first and then used while in 'i++' the value of i is used and then decremented. As said by Swapnil i=i+1 and i+=1 are equal and can be used anywhere possible.