function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype.method = function() {
alert(this.name + this.age);
};
function Student(name, age) {
Person.apply(this, arguments);
}
Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;
Student.prototype.method2 = function() {
alert("Bla-bla-bla");
};
var vasya = new Person('Василий', 25);
var petya = new Student('Петя', 18);
function type() {
(this.method2 !== undefined) ? alert('Student') : alert('Person');
}
type.call(vasya);
type.call(petya);