Programming Code Center(PCC)
[JS]

(PCC)::[How-to-use-The-decrement-operator-in-JavaScript]::[js]

File Name : index.html

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Operators</h2>

<p>In this example, y is decremented before it is assigned to x (pre-decremented).</p>

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

<script>
var y = 5;
var x = --y;
document.getElementById("demo1").innerHTML = y;
document.getElementById("demo2").innerHTML = x;
</script>

</body>
</html>

Output :

JavaScript Operators

In this example, y is decremented before it is assigned to x (pre-decremented).