함수는 마치 카멜레온 같습니다. 함수는 자신이 존재하는 컨텍스트에 따라 다양한 모습을 취합
니다. 우리가 가장 먼저 되짚어 볼, 가장 간단한 일면은 코드를 재사용하는 수단이라는 측면입
니다.
13.1
서브루틴으로서의 함수
서브루틴
subroutine
은 아주 오래 된 개념이며 복잡한 코드를 간단하게 만드는 기초적인 수단입니
다. 서브루틴이 없었다면 프로그래밍은 아주 지루한 반복의 연속이었을 겁니다. 서브루틴은 반
복되는 작업의 일부를 떼어내서 이름을 붙이고, 언제든 그 이름을 부르기만 하면 실행합니다.
서브루틴은 프로시저
procedure
, 루틴
routine
, 서브프로그램
subprogram
, 매크로
macro
등 다양한 이름으로 불립
니다. 이들은 모두 매우 단순하고 범용적인,
호출할 수 있는
한 단위를 일컫는 말입니다. 물론 자바스크립트에
서는 서브루틴이라는 용어를 쓰지 않습니다. 함수는 함수(또는 메서드)라고 부를 뿐이죠. 여기서 서브루틴이
라는 용어를 쓰는 이유는 함수의 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.