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

Conteúdo do Curso

Introduction to JavaScript

Introduction to JavaScript

1. JavaScript Fundamentals
2. Variables and Data Types in JavaScript
3. Performing Operations in JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
6. Functions in JavaScript

book
Increment and Decrement Operators

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.

question mark

Choose the correct result:

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
We're sorry to hear that something went wrong. What happened?
some-alt