강의

멘토링

커뮤니티

Inflearn Community Q&A

김태희's profile image
김태희

asked

[React Part 1] Learning React by Building and Comparing

[Pure JS 1] Search Form 3

문법 질문드립니다

Written on

·

253

0

 

위와 같이 value 를 객체로 보내주지 않아도 실행이 정상적으로 되는데 {value} 처럼 구조 분해 할당으로 전달하는것이 더 좋은 이유가 있을까요?

const { value } = this.inputElement;
this.emit("@submit", { value });

 

MVCreact

Answer 1

0

jeonghwan님의 프로필 이미지
jeonghwan
Instructor

메세지(value)를 전달하는 인터페이스(모양)는 정의하기 나름입니다. value 값을 직접 전달해도 동작하기만 하다면 괜찮다고 생각해요.

단 객체로 전달한 의도는 확장성인데요. value 필드 외에 필드를 추가하기 쉽기 때문입니다.

김태희's profile image
김태희

asked

Ask a question