Created
          September 22, 2019 16:57 
        
      - 
      
- 
        Save NyaGarcia/d1fbf34a251cfd5466f9b5a27f781576 to your computer and use it in GitHub Desktop. 
     Adding properties conditionally with spread operator
  
        
  
    
      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 pokemon = { | |
| name: 'Squirtle', | |
| type: 'Water' | |
| }; | |
| const abilities = ['Torrent', 'Rain dish']; | |
| const fullPokemon = { | |
| ...pokemon, | |
| ...(abilities && { abilities }) | |
| }; | |
| console.log(fullPokemon); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment