Куда записывается значение?
function Parent(args){
this.prop = args;
}
function Child(args){
Parent.call(this, args);
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
var child = new Child('test');
/**
* 1) Куда сохраняется строка 'test'
* при такой постановке?
*/
function Parent(args){
this.prop = args;
}
function Child(args){
Parent.call(this);
this.prop = args;
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
var child = new Child('test');
/**
* 2) Куда сохраняется строка 'test'
* при такой постановке?
*/
function Test(args){
this.prop = args; // присваивая значение здесь
}
Test.prototype = {
prop: undefined; // оно запишется сюда? Это вопрос 3.
}
var test = new Test('test');
Источник: Stack Overflow на русском