Javascript variable incrementing in evaluation?
<p>If I have </p>

<pre><code>a = 0;
if(a++ &lt; 1){
    console.log(a);
}
</code></pre>

<p>I get the value 1 in the console. If a became 1 with the incrementation, then why did the expression evaluate true? </p>

<p>If I do </p>

<pre><code>a = 0;
if(++a &lt; 1){
    console.log(a);
}
</code></pre>

<p>Then I don't get anything in the console, meaning the expression evaluated to be false. </p>

<p>I have always used <code>variable++</code> to increment variables in for loops and the like. I have seen the <code>++variable</code>, but I assumed it was another way to write the same thing. Can someone explain what happens and why? What's the difference between the two?</p>

<p>Does <code>++variable</code> increment the variable at the time of evaluation, while <code>variable++</code> increments after?</p>
