9
Argos
10d

Why do I hate JS so much.
It fucking drives me mad, seriously.

Comments
  • 7
    Because arr is not an object. Use let..of for arrays.
  • 6
    It makes sense to me, I could be wrong, but in JavaScript arrays are just objects, and keys in a JavaScript object are strings, so when you enumerate over an array using the `for ... in ... ` operator key will be a string. AFAIK in general one shouldn’t be enumerating over an array, but instead iterating over an array.

    EDIT: updated terminology
  • 3
    Arrays are objects. Their keys are "0", "1", etc. And for..in iterates over an object's keys.
  • 1
    @DrPitLazarus

    But let..of will iterate over values, not keys
  • 1
    @spongessuck

    That is what I wanted to say, this shit language don't even have normal arrays, it is a real pain to code on it
  • 0
    @Argos if you want to iterate over an array use a standard for statement.
    for(let i=0; i < arr.length; I++) {
    console.log(typeof I) // Number
    }

    JavaScript has a number of frustrating quirks, but the for statements aren’t one of them.
  • 0
    I only see user error, nothing broken :^)
  • 0
    "Normal language" -> PHP
  • 0
    @Sotch-pr35mac

    yeah I do, but 'let.. in' is way faster to type
Your Job Suck?
Get a Better Job
Add Comment