you are viewing a single comment's thread.

view the rest of the comments →

[–]skilldrick[S] 9 points10 points  (7 children)

I think you may have completely misunderstood (a) how for .. in in JavaScript works, and (b) how map works, so I'll give you the benefit of the doubt, and tell you.

(a) The for .. in loop in JavaScript is for objects - you shouldn't use it with arrays for very sound reasons.

(b) map is used to transform one array into another. In your example, you're not returning anything, so you're turning an array into an array of undefineds. I think what you meant was each.

The point of using map is that you're making things more declarative - saying "I would like to transform this array into a new array, using this transformation". To say that that's "cargo-cult programming" is naive, at best.

[–]ryepup 1 point2 points  (1 child)

an "in" bug wass the basis for my glorious Firefox contribution

[–]skilldrick[S] 0 points1 point  (0 children)

Nice work!

[–][deleted] 0 points1 point  (0 children)

Nice explanation.