Person is base class and Emp inherits from Person. I am trying to use name, location properties of Person in Emp.
function Person(name, location){
this.name = name;
this.location = location;
}
Person.prototype.getName = function(){
return 'Name: ' + this.name;
}
function Emp(id, name, location){
this.id = id;
Person.call(this, name);
Person.call(this, location);
}
Emp.prototype = Object.create(Person.prototype);
var e1 = new Emp(1, 'John', 'London');
e1.id // 1
e1.name // 'London'
e1.location //undefined
What is causing this error and why is name taking value of London?