이 기능의 샘플 :자바 스크립트 생성자 최우선
function User (name) {
this.options.name = name;
};
User.prototype.options = {
name: 'Default'
};
var foo = new User('foo');
var bar = new User('bar');
console.log(foo.options.name); // 'bar'
console.log(bar.options.name); // 'bar'
문제는, 어떻게 '갑'과 '바'를 얻을 수 있습니다? 감사합니다
알아 냈습니다. 고맙습니다! – Defari
구성원을 변경하고 할당하는 것은 차이가 있습니다. 프로토 타입에 공유 멤버를 지정하면 섀도 잉됩니다. 변경하면 모든 인스턴스의 공유 멤버가 변경됩니다. 여기에 자세하게 설명되어 있습니다 : http://stackoverflow.com/a/16063478/1641941 – HMR