Last active
December 27, 2015 11:59
-
-
Save lukehedger/7322467 to your computer and use it in GitHub Desktop.
CoffeeScript Array.filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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