Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

개발이야기

function의 arguments 본문

Javascript

function의 arguments

re2592 2020. 4. 11. 17:00

보통 자바스크립트 function을 보면

 

function hello(name){
	alert(name + "님 환영합니다.");
}

hello("홍길동");

이런식으로 구성되어 있다.

여기에 매개변수 name을 없애고 arguments를 활용해도 된다. 

즉, 

function Hello(){
	alert(arguments[0] + "님 환영합니다.");
}

hello("홍길동");

이렇게 쓸 수 있다. arguments는 매개변수에 따라 arguments[0], arguments[1] 등 이렇게 쓰면 된다.

 

Comments