Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Common CoffeeScript Idoms - from the little book on CoffeeScript

Common CoffeeScript Idoms

Each

myfunction(item) for item in items

Map

result = (item.name for item in items)

Select

result = (item for item in items when item.name is "foobar")

Include

included = "foobar" in ["bar", "foobar", "foo"]

Include in a string

foo = "A dog walks down a path in the park."
included = !!~ foo.indexOf "dog"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.