<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Incrementing and Decrementing Operators</title>
</head>
<body>
<h2>Incrementing and Decrementing Operators</h2>
<script>
var x;
// Declaring Variable
x = 10;
document.write('x = ', x, `<br>`);
document.write('++x = ', ++x, `<br>`); // Outputs: 11
document.write('x = ', x, `<br><br>`); // Outputs: 11
x = 10;
document.write('x = ', x, `<br>`);
document.write('x++ = ', x++, `<br>`); // Outputs: 10
document.write('x = ', x, `<br><br>`); // Outputs: 11
x = 10;
document.write('x = ', x, `<br>`);
document.write('--x = ', --x, `<br>`); // Outputs: 9
document.write('x = ', x, `<br><br>`); // Outputs: 9
x = 10;
document.write('x = ', x, `<br>`);
document.write('x-- = ', x--, `<br>`); // Outputs: 10
document.write('x = ', x); // Outputs: 9
</script>
</body>
</html>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.