Skip to content

Instantly share code, notes, and snippets.

@lukehedger
Last active December 27, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukehedger/7322467 to your computer and use it in GitHub Desktop.
Save lukehedger/7322467 to your computer and use it in GitHub Desktop.
CoffeeScript Array.filter
array = [
{
"id":"1",
"type":"a"
},
{
"id":"2",
"type":"b"
}
]
filtered = array.filter (element) =>
return element.type != 'a'
# filtered = [{"id":"2","type":"b"}]
# PLUS - call this anywhere in your script for IE8 support
do -> Array::filter ?= (callback) ->
element for element in this when callback element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment