Created
December 27, 2012 18:24
-
-
Save crtr0/4390616 to your computer and use it in GitHub Desktop.
Can anyone explain why the if statement below never succeeds? I am running it as part of a Node.js v0.8.7 app.
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 arr = ['a', 'b', 'c']; | |
for (i in arr) { | |
if (i === 0) { | |
console.log('do something special') | |
} | |
} | |
// sadly, that console.log never happens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're right, but why isn't it an integer in the first place? Why is it "0", "1" and "2" instead of 0, 1 and 2?