Last active
July 17, 2016 22:39
-
-
Save stowball/082f077574059bbd5e14fc05bb948ee4 to your computer and use it in GitHub Desktop.
Imperative vs Declarative
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
| vm.availableFields = rsDataModel.fields.map(function (field) { | |
| return field.childFields.length ? field.childFields : field; | |
| }).reduce(function (prev, curr) { | |
| return prev.concat(curr); | |
| }, []); |
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
| vm.availableFields = []; | |
| rsDataModel.fields.forEach(function (field) { | |
| if (field.childFields.length) { | |
| field.childFields.forEach(function (childField) { | |
| vm.availableFields.push(childField); | |
| }); | |
| } | |
| else { | |
| vm.availableFields.push(field); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment