자바스크립트 콜백함수(callback function) 사용법

By | 11월 29, 2011

* 콜백함수 문법은 특정 함수의 동작이 끝남과 동시에, 다른 여러가지 함수를 호출해야 할 경우에 사용된다.

// 콜백함수 정의

function callbackTest(arg){
     alert(arg);
}

// 콜백함수를 호출할 함수 정의
function test( arg1, arg2, callback ){
     if( typeof callback == "function" ){
         callback();
     }
}

// 함수 호출부
test( 'a', 'b', callbackTest('xxx') );

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
정존
10 years ago

내용 담아갑니다. 출처 남길께요.

호러블캣
10 years ago
Reply to  정존

네네~