7

Devs who use the array map method for purposes other than generating a new array, and who use an empty return statement to satisfy the linter, should receive a slap in the face. A gentle one, but a slap nonetheless

Comments
  • 2
    We have for..in loops for procedural iteration and reduce for functional iteration. Programmers who use map with anything other than a pure function except possibly for caching deserve a hard slap IMO.
  • 0
    You obviously dont know what the uses of map are :)
  • 1
    @catgirldev @fullstackchris my rant is lacking context as it was written on the spur of the moment out of frustration. The code that sparked the frustration was an array map where the returned array was not being assigned to anything, it was just feeding an object declared above. However the map callback method ended with a return ""
    I can only assume they were trying to satisfy a linter (and it was a failed attempt). A forEach or reduce would have been more appropriate. But I still I see a lot of code where map is being used instead.
    Sorry if my wording is not always adequate …
Add Comment