Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: chap17 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat: chap17 #1

wants to merge 2 commits into from

Conversation

hayoung0Lee
Copy link
Member

생성자 함수 부분 정리했습니다.

Copy link
Member

@1ilsang 1ilsang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다. 아래 내용 확인해주세요~

}
```

생성자 함수는 객체를 생성하는 템플릿처럼 이런 생성자 함수를 통해서 프로퍼티 구조가 동일한 인스턴스를 쉽게 반복적으로 생성할 수 잇따.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잇따

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이제 발견함옄ㅋㅋㅋㅋㅋ 고칠게요!!


# 객체 리터럴 방식이 아니라 생성자 함수를 사용하는 이유

아래는 객체 리터럴 방식을 통해서 객체를 생성하는 경우인데, 이때 동일한 프로퍼티를 가진 객체를 여러개 생성할 때 같은 객체 리터럴 방식으로 프로퍼티를 기술해야하는 점이 비효율 적이다. 또한 state와 같은 프로퍼티는 객체마다 다를 수 있지만 `getState`와 같은 메서드는 내용이 공통인 경우가 있는데, 이런 메소드 선언이 반복되는 것이 문제가 될 수 있다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체 리터럴 방식으로 프로퍼티를 기술해야하는 점이 비효율 적이다.

이런 메소드 선언이 반복되는 것이 문제가 될 수 있다.

각 상황에 맞는 예시코드가 있으면 더 좋을것 같아요!

```javascript
function func1() {
if(!new.target){
return new func();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func1 이라고 해주어야 하겠네요.

}
```

이를 통해서 생성자로 호출 되지 않은 경우에도 인스턴스를 생성해서 반환한다. 되지
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

되지..?

@soobing soobing self-requested a review May 2, 2021 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants