티스토리 뷰

Programming

parameter와 argument의 차이

junojuno 2021. 9. 30. 22:47

<parameter와 argument의 차이점>

function 정의 할때 괄호 안에 적는 변수의 이름이 function parameter이다.

function argument는 function을 통해서 전달되는 실제 값들이다.

parameter는 argument가 공급된것의 값으로 초기화 된다.

 

Example)

// addend1, addend2는 parameter
function sum(addend1, addend2){
	return addend1 + addend2
    }

// sum()로 runtime에서 넘기는건 argument
let value1 = 40;
let value2 = 2;
let sumValue = sum(value1, value2);

parameter는 변수고, argument는 literal이나 다른것들이 올수 있다

대략적으로, parameter는 type이고 argument는 instance이다.

 

출처 : 

https://developer.mozilla.org/en-US/docs/Glossary/Parameter

 

Parameter - MDN Web Docs Glossary: Definitions of Web-related terms | MDN

A parameter is a named variable passed into a function. Parameter variables are used to import arguments into functions.

developer.mozilla.org

https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29#Parameters_and_arguments

 

Parameter (computer programming) - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search An input provided to a function/subroutine In computer programming, a parameter or a formal argument is a special kind of variable used in a subroutine to refer to one of the pieces of

en.wikipedia.org

 

'Programming' 카테고리의 다른 글

스트랭글러 패턴  (0) 2023.05.31
Clean Code - 냄새와 휴리스틱 (일반)  (0) 2022.11.01
Clean Code 책을 읽고  (0) 2022.11.01
질문을 잘 하는 개발자가 되자  (2) 2022.10.28
마크다운 연습  (0) 2022.01.03
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday