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?

6 of 8 people (75%) answered Yes
Recently 4 of 5 people (80%) answered Yes

Entry

when passing a parameter to a function that may or may not be another function how would you test the parameter to see if it is a function or not?

May 15th, 2001 09:52
Thor Larholm, Peter Parker,


Use the typeof operator to determine the type of an object, even if it 
doesn't exists, e.g.:
if (typeof something == "function"){
  something('somestring')
}
typeof operator:
http://msdn.microsoft.com/scripting/jscript/doc/jsoprtypeof.htm