Skip to content

Instantly share code, notes, and snippets.

@stowball
Last active July 17, 2016 22:39
Show Gist options
  • Select an option

  • Save stowball/082f077574059bbd5e14fc05bb948ee4 to your computer and use it in GitHub Desktop.

Select an option

Save stowball/082f077574059bbd5e14fc05bb948ee4 to your computer and use it in GitHub Desktop.
Imperative vs Declarative
vm.availableFields = rsDataModel.fields.map(function (field) {
return field.childFields.length ? field.childFields : field;
}).reduce(function (prev, curr) {
return prev.concat(curr);
}, []);
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