Created
January 31, 2017 15:41
-
-
Save tylergaw/5c223bd26a0f0bd92fc332cc01d24a60 to your computer and use it in GitHub Desktop.
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
| // 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 | |
| }) | |
| } | |
| ` : ''; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.