1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【JS】インクリメント/デクリメントでつまずいたところ

Last updated at Posted at 2020-02-13

無限ループにハマったので調べました...


// 普通に足してみる
let n = 5
console.log(n)
// 5
console.log(n + 1)
// 6 元の値には影響しない
console.log(n)
// 5

// 後述の場合
let n = 5
console.log(n)
// 5
console.log(n++)
// 5 nの値を返した後に、1プラスする
console.log(n)
// 6
// 前述の場合
let n = 5
console.log(n)
// 5
console.log(++n)
// 6 nの値をプラス1した後に、その値を返す
console.log(n)
// 6
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?