コンストラクション関数とプロトタイプのコンストラクション関数構成
4732 ワード
https://wikibook.co.kr/mjs/
P.271
P.271
function Person(name) {
this.name = name;
}
const me = new Person('Lee');
console.log(me.__proto__ === Person.prototype); // true
P.272console.log(me.constructor === Person); // true
console.log(me.__proto__.constructor === Person); // true
継承Person.prototype.sayHi = function () {
console.log('Hi: ' + this.name);
}
const you = new Person('Lyu');
me.__proto__
you.__proto__.sayBye = function () {
console.log('Bye: ' + this.name);
}
Person.prototype
Reference
この問題について(コンストラクション関数とプロトタイプのコンストラクション関数構成), 我々は、より多くの情報をここで見つけました https://velog.io/@youngkiu/생성자-함수와-프로토타입의-constructor-프로퍼티テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol