Created
March 16, 2016 17:23
-
-
Save BlakeWilliams/35c7bb1069629fb28e95 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
| const json = '[]'; // pretend this is the result of some api request | |
| let jsonValue = JSON.parse(json); | |
| if (json === null) { | |
| jsonValue = []; | |
| } |
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
| const json = '[]'; // pretend this is the result of some api request | |
| const jsonValue = JSON.parse(json) || []; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Makes sense. Prefer to avoid the ability for mutation when possible. Thanks.