Inheritance

by vysohanych

JavaScript

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

// Напишіть функцію, яка наслідується від Person
// і дозволяє просетити ім'я через конструктор

function Me(name){
    this.name=name;
};

Me.prototype = new Person();

Me.prototype.setName = function(name){
  this.name=name;
};

var me = new Me();

me.setName("Vitaliy");

console.log(me.getName());