1. function 함수명 ( ) {반복하고자 하는 코드}
document.write('A');
document.write('B');
document.write('C');
document.write('A');
document.write('B');
// A와B 출력되는 코드를 반복하고자 한다.
function AB()
{ document.write('A');
document.write('B');
}
document.write('C');
AB();
// => function 으로 함수값을 지정해 함수명() 만으로 간단화할 수 있다.
2. Parameter : 매개변수
Argument : 인자
function sum(x,y) // 여기서 x,y 가 parameter(매개변수)
{
document.write(x+y);
}
sum(1,2) // (1,2)와 (5,6) 는 argument(인자)
sum(5,6) // 즉, 지정된 매개변수의 자리에 들어가는 구체적인 값.
'ONLINE COURSES > JavaScript' 카테고리의 다른 글
Basics-3 function // loops // iterations (0) | 2021.06.13 |
---|---|
Basics-2 (0) | 2021.06.12 |
Basics-1 (0) | 2021.06.12 |
Object 객체 { } (0) | 2021.05.31 |
조건문, 반복문while을 활용해 화면모드 바꾸기 (0) | 2021.05.29 |
댓글