I am learning composition in Javascript and was wondering why Object.assign() in my code is adding methods to the prototype's constructor rather than the object's constructor. I will link the code below. Basically, the code is adding two methods (eat and walk) to the Person object by using Object.assign(). But, as the image below shows, the console is displaying the methods as belonging to the Person.prototype's constructor rather than the Person object itself. I must be overthinking it. Any help is appreciated. Thanks!
Code
const canEat = {
eat() {
this.hunger--;
console.log('eating');
}
};
const canWalk = {
walk: function() {
console.log('walking');
}
};
const canSwim = {
swim: function() {
console.log("swim");
}
};
function Person() {
}
Object.assign(Person,canEat,canWalk);
const person = new Person();
console.log(person);