Post increment gotcha
Try to answer this without testing:
c=2;
c = 1 + c++;
// c = 3 or 4 ?
Compare it to:
c=2;
c = 1 + (++c);
// c = 3 or 4 ?
Finally:
c=[1,2,3];
i = 1;
c[i] = i++:
// c[1] = 1 or 2, or c[2] = 2 ?Written by Alexander Brevig
Related protips
1 Response
i enjoyed this brain exercise! a very original tip -- kudos.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Csharp
Authors
Filed Under
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#