Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Increment and Decrement | Basic Operations
Introduction to JavaScript
course content

Contenido del Curso

Introduction to JavaScript

Introduction to JavaScript

1. Basic Concepts
2. Variables and Data Types
3. Basic Operations
4. Conditional Statements
5. Loops
6. Functions

book
Increment and Decrement

Increment and Decrement are operations used to increase or decrease a variable's value by 1.

Increment

The increment operation is performed using the ++ operator:

1234567
let a = 0; a++; console.log(a); a++; console.log(a); a++; console.log(a);
copy

Note

The expression a++ is equivalent to a = a + 1 or a += 1.

Decrement

The decrement operation is performed using the -- operator:

1234567
let a = 5; a--; console.log(a); a--; console.log(a); a--; console.log(a);
copy

Note

The expression a-- is equivalent to a = a - 1 or a -= 1.

Increment and decrement operations are frequently used in loops, which we will discuss in more detail later.

Choose the correct result:

Choose the correct result:

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
We're sorry to hear that something went wrong. What happened?
some-alt