Skip to content

Instantly share code, notes, and snippets.

@jeremyhalliwell
Last active July 11, 2020 16:38
Show Gist options
  • Save jeremyhalliwell/4b76adde2633bf496b020b68d0876eb4 to your computer and use it in GitHub Desktop.
Save jeremyhalliwell/4b76adde2633bf496b020b68d0876eb4 to your computer and use it in GitHub Desktop.
<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