putting ++ before a variable name means incrementing it before use, and putting it after the variable name means incrementing after use. same goes for --
So
leta=0;// this is falsey because 0if(a++){// here a will be checked by if and then become 1console.log("I won't run, a =",a);}else{console.log("I will run, a =",a);// This will print "I will run, a = 1"}
and
leta=0;// this is falsey because 0if(++a){// here, a will become 1 before being checked with ifconsole.log("I will run, a =",a);// This will print "I will run, a = 1"}else{console.log("I won't run run, a =",a);}
Feel free to try these snippets in your browser console.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
putting ++ before a variable name means incrementing it before use, and putting it after the variable name means incrementing after use. same goes for --
So
and
Feel free to try these snippets in your browser console.