홍익인간 프로젝트/참조

Pass a JavaScript function as parameter

remoted 2020. 12. 1. 02:07
728x90

This then passes the function without executing it first.

Here is an example:

function addContact(id, refreshCallback) {
    refreshCallback();
    // You can also pass arguments if you need to
    // refreshCallback(id);
}

function refreshContactList() {
    alert('Hello World');
}

addContact(1, refreshContactList);