• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

소스코드에 관련하여 질문드립니다.

18.10.19 22:37 작성 조회수 142

1

function Person(){

this.introduce = function() {

return 'My name is '+this.name;

}

}

function Programmer(name){

this.name = name;

this.coding = function() {

return "hello world";

}

}

Programmer.prototype = new Person();

function Digner(name) {

this.name = name;

this.Beautiful = function() {

return "beautiful!";

}

}

Digner.prototype = new Person();

var p1 = new Programmer('egoing');

console.log(p1.introduce());

console.log(p1.coding());

var p2 = new Digner('hihihi');

console.log(p2.introduce());

console.log(p2.Beautiful());

이렇게 짠 코드에대해서는 어떻게 생각하시는지 여쭙고 싶어서 질문드립니다.

prototype의 사용을 줄여봤는데 이것의 문제점이나 잘못된 점과

만약 강사님이 작성하신 코드가 더 좋은 코드라면 그 이유에 대해서도 알려주시면 감사드리겠습니다.

항상 강좌 잘 보고 있습니다. 감사합니다.

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!