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:
1234567let a = 0; a++; console.log(a); a++; console.log(a); a++; console.log(a);
Note
The expression
a++is equivalent toa = a + 1ora += 1.
Decrement
The decrement operation is performed using the -- operator:
1234567let a = 5; a--; console.log(a); a--; console.log(a); a--; console.log(a);
Note
The expression
a--is equivalent toa = a - 1ora -= 1.
Increment and decrement operations are frequently used in loops, which we will discuss in more detail later.
フィードバックありがとうございます!
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
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:
1234567let a = 0; a++; console.log(a); a++; console.log(a); a++; console.log(a);
Note
The expression
a++is equivalent toa = a + 1ora += 1.
Decrement
The decrement operation is performed using the -- operator:
1234567let a = 5; a--; console.log(a); a--; console.log(a); a--; console.log(a);
Note
The expression
a--is equivalent toa = a - 1ora -= 1.
Increment and decrement operations are frequently used in loops, which we will discuss in more detail later.
フィードバックありがとうございます!