Skip to content

Instantly share code, notes, and snippets.

@tylergaw
Created January 31, 2017 15:41
Show Gist options
  • Select an option

  • Save tylergaw/5c223bd26a0f0bd92fc332cc01d24a60 to your computer and use it in GitHub Desktop.

Select an option

Save tylergaw/5c223bd26a0f0bd92fc332cc01d24a60 to your computer and use it in GitHub Desktop.
// a) IIFE
const employmentFields = employmentInfo ? (() => {
const occupation = new TextInput({
fieldName: 'gwb-occupation',
label: 'Occupation',
targetId
});
const employer = new TextInput({
fieldName: 'gwb-employer',
label: 'Employer',
targetId
});
return `${occupation}${employer}`;
})() : '';
// b) Just a template string
const employmentFields = employmentInfo ? `
${
new TextInput({
fieldName: 'gwb-occupation',
label: 'Occupation',
targetId
})
}
${
new TextInput({
fieldName: 'gwb-employer',
label: 'Employer',
targetId
})
}
` : '';
@tylergaw
Copy link
Author

tylergaw commented Feb 9, 2017

Was asking co workers which one of these they preferred. Got an enthusiastic 👍 for A, the IIFE from two. Same. While B is fewer keystrokes it loses clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment