Skip to content

Javascript 익명함수 호출 문법의 가장 바깥쪽 괄호()에 대해.. #169

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

Closed
dhchoi82 opened this issue Jan 20, 2018 · 2 comments

Comments

@dhchoi82
Copy link

dhchoi82 commented Jan 20, 2018

안녕하세요?
생활코딩 Javascript 강의 중 유효범위에 대한 부분( https://opentutorials.org/course/743/6495 )을 보다가 질문 드립니다. 위 페이지 3/5 영상을 보면 익명함수를 사용할 때에는 function(){}() 전체를 괄호()로 감싸야 한다고 나오는데요. 크롬개발자도구에서 괄호()로 감싸지 않으면 에러가 나는 것을 확인할 수 있었습니다.
image
하지만 이벤트리스너를 추가할 때에는 괄호로 감싸지 않고, 실행을 위한 마지막부분의 괄호를 뗀 function(){} 형태를 사용해야 제대로 동작하는데요...
image
문법적으로 어떤 차이가 있는지 궁금합니다.

@azaraks
Copy link

azaraks commented Jan 20, 2018

이름없는 function expression은 있지만 이름없는 function declaration은 없습니다.

@dhchoi82
Copy link
Author

dhchoi82 commented Jan 30, 2018

@azaraks2 님, 답변 감사합니다. 근데 잘 이해가 안되네요. 무얼 모르는 건지 몰라 제가 질문을 잘못한 것 같습니다. 일단 활용에는 큰 지장이 없으니 다음에 기회가 있으면 차차 알아가는 게 나을 것 같네요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants