Last active
December 31, 2019 06:53
-
-
Save rcdexta/12a0cdcde885330c0d506c5994e06a3f 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
| // Prior to v3.7 | |
| if (data && data.customer && data.customer.address) { | |
| const {address} = data.customer | |
| const fullAddress = `${address.street}, ${address.city}, ${address.state }${address.zipcode}` | |
| } | |
| // v3.7 onwards | |
| // data access | |
| const address = data?.customer?.address | |
| const fullAddress = `${address?.street}, ${address?.city}, ${address?.state } ${address?.zipcode}` | |
| // also works with arrays | |
| customers?.[0]?.['address'] | |
| // check if method defined and call | |
| customer.approve?.() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment