Использование пустого конструктора

by Artem

JavaScript

var Parent = function(name) {
  this.name = name;
};

Parent.prototype = {
  parentProp: 1
};

var Child = function() {
  Parent.call(this, arguments[0]);
};

var EmptyConstructor = function() {};
EmptyConstructor.prototype = Parent.prototype;
Child.prototype = new EmptyConstructor();

var child = new Child(1);
console.dir(child);