놀라움을 서술하기 이전에 argument와 parameter가 뭐가 정확히 다른 건지 모르겠어서 그것부터 잡고 가려고 합니다,,,
https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter
What's the difference between an argument and a parameter?
When verbally talking about methods, I'm never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what's correct, and what's the
stackoverflow.com
바로 스택오버플로우 들어갔는데 무려 [현직 프로그래머]도 헷갈리신다는 글을 보고 내 머리가 나쁜 게 아님을 깨달았다... 답변을 읽어 보니!
- Parameter is the variable in the declaration of the function.
- Argument is the actual value of this variable that gets passed to the function.
파라미터는 placeholder의 기능을 하는 variable이라고 이해를 하면 되고(함수를 선언할 때 쓰이는) argument는 정말 함수가 실사용될 때 실제로 입력되는 값이라구 한당ㅎㅎ 완벽 이해!! 하지만 또 논의가 있어서 가져왔는데...
The general consensus seems to be that it's OK to use these terms interchangeably in a team environment. Except perhaps when you're defining the precise terminology; then you can also use "formal argument/parameter" and "actual argument/parameter" to disambiguate.
그렇다구 한다ㅋㅋㅋㅋ parameter든 argument이든 협업 환경에서 딱히 엄격하게 구분해서 부르지는 않는 것 같당! 그래도 알고 있어서 손해볼 건 없으니 이런 건 근본부터 정확하게 알고 있어야 한다.
암튼... 글을 쓰게 된 이유는
function을 variable에 할당하니 variable이 argument를 받아들일 수 있게 된 것에 충격을 받아서였다... 넘넘 신기해...
const plantNeedsWater = function(day) {
if(day === 'Wednesday') {
return true;
} else {
return false;
};
};
console.log(plantNeedsWater('Tuesday'));
plantNeedsWater같은 경우에는 함수가 할당되지 않고 그냥 변수로 남았으면 argument를 받을 수 없었을 텐데 함수가 할당되니 argument를 받아서 뭔가 return을 하고 있다!!!!! 넘 신기해!!!!! 하 너무 재밌다............................
'개발 일기' 카테고리의 다른 글
[Git] 그래서 Git은 어떻게 시작하는 건데? (0) | 2022.09.22 |
---|---|
[Git] What is Git and GitHub? (0) | 2022.09.22 |
[Javascript] hoisting을 방지하기 위해서 function declaration보다 function expression을 활용하는 게 나을까? (1) | 2022.09.21 |
[Javascript] visual studio 2022 설치 방법 (1) (1) | 2022.09.20 |
[JavaScript] If else와 Ternary Operator는 어떻게 다를까? (0) | 2022.09.17 |