Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How do you select different specific properties of an object in the composition pattern?

/* how can I selectively pick 
which properties I want to use 
from two or more objects to 
create a new object. ? */

Let mammal ={
          metabolismType: "warm blooded" ,
         birthType: "live birth",
         hasHair: true,
};

Let reptile={
     metabolismType: "cold blooded",
     birthType: "lays eggs",
     hasScales: true
};


Let dog= Object.create(mammal);
dog.legs=4;
dog.diet="carnivore";


Let cat=Object.assign({},dog);
cat.diet="Strict carnivore"; 

Let snake= Object.assign({}, reptile, {legs, diet}= cat);
snake.legs=0;

Let viper= Object.create(snake);
Viper.hasVenom=true;
/**I tried destructer it but that doesn't work and in 
hind sight I can see why because I would 
be passing multiple varibles as one argument. 
I'm sure I can destructer outside of the assign
 method then pass those 
variables in but that seems tedious 
and like I would be 
variable polluting so I sure there is a better way.
**/
Let platypus= Object.assign({}, mammal,
{birthType,hasVenom}=viper);