Created
November 16, 2012 16:33
-
-
Save sadah/4088752 to your computer and use it in GitHub Desktop.
pre-incrementとpost-incrementの違い
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 1; | |
// +1 される前の値が出力されるのが i++ | |
console.log(i++) // 1 | |
// そして次に呼び出すときには +1 されている | |
console.log(i) // 2 | |
var j = 1; | |
// +1 された後の値が出力されるのが ++j | |
console.log(++j) // 2 | |
console.log(j) // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment