Last active
November 20, 2015 10:33
-
-
Save holyjak/10c11a436cd1cfd97541 to your computer and use it in GitHub Desktop.
Simple or Complex? Familiar Imperative Code Or Makes-Me-Think Declarative One?
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
// Using http://lodash.com/ as `_` | |
// 1. IMPERATIVE | |
_(bundles).filter(function includeOnlyHandsets(bundle) { | |
if (!filter.hardwareType) return true; | |
return (bundle.product.type === filter.hardwareType); | |
}) | |
// 2. DECLARATIVE | |
_(bundles).filter(filter.hardwareType ? | |
{bundle: {product: {type: filter.hardwareType}}} : null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment