Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
return 명령문은 함수 실행을 종료하고, 주어진 값을 함수 호출 지점으로 반환합니다.
반환할 값으로 사용할 표현식. 생략할 경우 undefined를 대신 반환합니다.
함수 본문에서 return 명령문에 도달하면 함수의 실행은 그 지점에서 중단됩니다. 값을 제공한 경우 함수를 호출한 곳에 그 값을 반환합니다. 예를 들어, 다음 함수는 숫자 매개변수 x의 제곱을 반환합니다.
값을 명시하지 않으면 대신 undefined를 반환합니다.
다음 return 명령문 모두 함수 실행을 끊습니다.
return 명령문은 자동 세미콜론 삽입(ASI)의 영향을 받습니다. return 키워드와 표현식 사이에는 줄바꿈 문자가 올 수 없습니다.
위 코드는 ASI로 인해 아래처럼 처리됩니다.
콘솔이 "unreachable code after return statement" 경고를 출력할 것입니다.
문제를 해결하려면 괄호를 사용해 ASI를 방지해야 합니다.
함수는 return을 호출하는 지점에서 즉시 실행을 멈춥니다.
클로저에 대해서도 더 알아보세요.
| ECMAScript® 2027 Language Specification # sec-return-statement |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 6월 27일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.