Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 337 Bytes

006-coffeescript-comprehensions.md

File metadata and controls

22 lines (15 loc) · 337 Bytes

How to use comprehensions in CoffeeScript

Take advantage of comprehensions whenever possible. Instead of:

results = []

for item in array
  results.push(item.name)

Use:

results = (item for item in array)

With filtering:

inputs = (input for input in inputs when input.type isnt "hidden")