eyabc / blog-comment

1 stars 0 forks source link

Object essentials 객체의 본질 | Respect myself #40

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Object essentials 객체의 본질 | Respect myself

객체가 진짜로 해야만 하는 책임

https://eyabc.github.io/docs/javascript/OOP_object_essentials

khw970421 commented 3 years ago

setAge 부분은 혹시 어디부분인가요??

eyabc commented 3 years ago

@khw970421

본문에는 적지 않았네요 감사합니다!

예를들어

const eunyoung = new (class Person {
    age;

    setAge(val) {
        this.age = val;
    }

})

eunyoung.setAge(1);

이런 식으로 eunyoung 의 멤버 변수인 age 를 인스턴스 외부에서 setAge 라는 메서드를 통해 내부의 멤버 변수 값을 변경하는 행위를 의미합니다!