Trouble understanding property iterating

Why do you check if beagle has the property ‘property’ first? From the function, is beagle not supposed to be guaranteed to have all the properties in Dog? So aren’t we supposed to check if the property is in Dog first, then if it took in a variable, it wouldn’t be, so it would be in beagle?

function Dog(name) { = name;

Dog.prototype.numLegs = 4;

let beagle = new Dog("Snoopy");

let ownProps = [];
let prototypeProps = [];

// Only change code below this line

for (let property in beagle){
} else{

Challenge: Iterate Over All Properties

Link to the challenge:

Beagle doesn’t have a numLegs, that only exists in the Dog.prototype. So any object that uses the new Dog constructor will be able to reference those prototype properties, but unless you override them (for example, beagle.numLegs = 3), any prototype property is not owned by the constructed object. is it’s own property, as the constructor is sticking it in the object being constructed via the

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.