<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="utf-8">
    <title>JavaScript Operator Increment dan Decrement</title>
</head>
<body>
    <script>
    var x; // Deklarasi Variabel
 
    x = 10;
    document.write(++x); // Cetak: 11
    document.write("<p>" + x + "</p>");   // Cetak: 11
     
    x = 10;
    document.write(x++); // Cetak: 10
    document.write("<p>" + x + "</p>");   // Cetak: 11
     
    x = 10;
    document.write(--x); // Cetak: 9
    document.write("<p>" + x + "</p>");   // Cetak: 9
     
    x = 10;
    document.write(x--); // Cetak: 10
    document.write("<p>" + x + "</p>");   // Cetak: 9
    </script>
</body>
</html>

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.