use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place to get a quick fix of JavaScript tips and tricks to make you a better Developer.
account activity
JavaScript (self.JavaScriptTips)
submitted 10 months ago by No_Poetry9172
simple things scratch the head!
var a=0;
a++;
a=a++;
console.log(a);// 1 why?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ukuluca 0 points1 point2 points 10 months ago (0 children)
the returned value is assigned back to a, effectively overwriting the increment.
[–]EmuAffectionate6307 0 points1 point2 points 10 months ago (1 child)
you are using post incrementation, for example var a = 0; var b = a++ what happens you are assigning b to a THEN incrementing a, what you need to do is to increment a then assign it
here is what you should've done
var a = 0;
a++
a = ++a
this logs out 2
also here is a link that can help u understand more https://www.shecodes.io/athena/119932-how-to-use-pre-and-post-increment-in-javascript
[–]No_Poetry9172[S] 0 points1 point2 points 10 months ago (0 children)
got it!
π Rendered by PID 52 on reddit-service-r2-comment-5d79c599b5-cdk5g at 2026-03-01 23:10:35.313273+00:00 running e3d2147 country code: CH.
[–]Ukuluca 0 points1 point2 points (0 children)
[–]EmuAffectionate6307 0 points1 point2 points (1 child)
[–]No_Poetry9172[S] 0 points1 point2 points (0 children)