Skip to content

18. JavaScript: Object Constructors

Colleen edited this page Oct 9, 2015 · 2 revisions

Assignment Solution

function Stark(){}
Stark.prototype.getName = function() {
  return this.name;
};

function Arya(){ 
  this.name = "Arya Stark"; 
} 
Arya.prototype = new Stark(); 
 
var arya = new Arya();
arya.getName();