Prototypes page

Learn how to explore an object’s proto chain.

The problem

What is the value of frozen’s rated property that it inherited from the Entertainment prototype?

<script src="//bitovi.github.io/academy/static/scripts/debugging/variables.js"></script>
<script type="module">
var Movie = function(){};
Movie.prototype = new Entertainment();
Movie.prototype.play = function(){};

var AnimatedMovie = function(){};
AnimatedMovie.prototype = new Movie();
AnimatedMovie.prototype.isAnime = function(){};

var frozen = new AnimatedMovie();
console.log("frozen has a `rated` property, inherited from Entertainment. What is its value?")
console.log(frozen);
</script>

What you need to know

The following sets up the same Animal, Chordate, and Mammal inheritance chain from the Prototypes JavaScript course.

Animal = function(name) { this.name = name; };
Animal.prototype.eats = function(){ return this.name+" eats."; };

function Chordate(name){ this.name = name; };
Chordate.prototype = new Animal();
Chordate.prototype.hasSpine = true;

function Mammal(name){  this.name = name; };
Mammal.prototype = new Chordate();
Mammal.prototype.hasHair = true;

var m = new Mammal('dog');
console.log(m);

You can inspect the Mammal instance m and see its __proto__ property:

The solution

Click to see the answer

The answer is b.