calculate x = y++, ++ after variable - Javascript Operator

Javascript examples for Operator:Arithmetic Operator

Description

calculate x = y++, ++ after variable

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<p id="demo1"></p>
<p id="demo2"></p>

<script>
function myFunction() {//from  w  ww  .  j a  v a  2  s  . com
    var y = 5;
    var x = y++;
    document.getElementById("demo1").innerHTML = y;
    document.getElementById("demo2").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials