function baseClass(name) {
this.name = name;
this.getName = function() {
return this.name;
}
}
function subClass(id, company){
baseClass.call(this);
this.id = id;
this.company = company;
this.toString = function() {
return name + "\n" + this.id + "\n" + this.company;
}
}
subClass.prototype = Object.create(baseClass);
var s = new subClass();
s.toString(); //here the name property from the baseClass is not displayed.
가 제대로 (/ 클래식 원형)
[가능한 중복] (http://stackoverflow.com/questions/16020577/proper-prototypal-inheritance) 45 분 전. 또한 EcmaScript (자바 스크립트)는 프로토 타입 언어이기 때문에 고전을 잊어 버리십시오. – GitaarLAB
"클래식/프로토 타입"- 어느 것을 의미합니까? – Pointy
JavaScript는 ** 프로토 타입 ** 언어이므로 _classical_은 없습니다 ... – War10ck