Last active
July 11, 2020 16:38
-
-
Save jeremyhalliwell/4b76adde2633bf496b020b68d0876eb4 to your computer and use it in GitHub Desktop.
This file contains 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
<cfscript> | |
arr = [ | |
'foo','foo','bar','baz','foo' | |
]; | |
filteredArr = arr.reduce( ( result=[],item ) => { | |
return result.find( item )? result: result.append( item ); | |
}); | |
dump( filteredArr ); | |
arr = [ | |
{ name: 'foo'}, | |
{ name: 'foo'}, | |
{ name: 'bar'}, | |
{ name: 'baz'}, | |
{ name: 'foo'} | |
]; | |
filteredArr = arr.reduce( ( result=[],item ) => { | |
return result.find( item )? result: result.append( item ); | |
}); | |
dump( filteredArr ); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment