Printing out a object doesnt show all the property inherited


#1


https://www.codecademy.com/en/courses/objects-ii/3/5?curriculum_id=506324b3a7dffd00020bf661


i can print this folllowing:

console.log(emperor.name)
console.log(emperor.numLegs)

but when i print "emperor", it doesnt show all the properties (i.e name and numLegs), why?

console.log(emperor)


function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name) {
    this.name = name;
}

Emperor.prototype = new Penguin()

// create an "emperor" object and print the number of legs it has

var emperor = new Emperor("emperor")

console.log(emperor.numLegs)
console.log(emperor.name)
console.log(emperor)


#2

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