faqts : Computers : Programming : Languages : JavaScript : Language Core : Functions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

74 of 86 people (86%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How do you pass a function as a parameter to another function, and then use that parameter to call that function?

Apr 16th, 2000 08:43
Martin Honnen, Michael Davies,


There is no difference to other arguments/parameters
  function f1 (fun) {
    fun();
  }
Here is a complete example:

function f1 (fun) {
  fun();
}
function f2 () {
  alert('JavaScript.FAQTs.com');
}
f1(f2)