Skip to content

Comment on Don't use CoffeeScript

Comments

Hey quick question, maybe you should use map instead of filter?

http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=117 (random site with example)

map is the functional equivalent of what you're trying to do there, not filter.

His criticism still stands that the JS implementation of

  (number * number for number in nums)
...is inefficient, and that it could've been translated into much more efficient JS than it was.

It's really not inefficient though. Array.map will be much slower in just about all environments.

[EDIT] - People have followed up, turns out the comprehension is faster.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.