[RESOLVED]Question on functional programming

Javascript is a functional programming language. So instead of passing a simple value parameter to a function, you can pass an actual function as the parameter. Is this correct?

Question is, how does the function handle this as a parameter, because it is not an actual value is it. Doesn’t the function being passed in need to be supplied an input in order to return a value, and if so is it the output from the passed in function that
is used as the parameter? If this does not make sense, let me know,


You can pass in a function as a callback so:

function doSomething(callBack){


  var value =  callBack();






There are other ways to call or pass in functions but the callback in javascript is really useful – especially where you’re using AJAX and need to run something when you get a response…

javascript isn’t a functional programming language.  A functional language concentrates on function inputs and outputs using variables, and standard program flow.  It isn’t concerned with stateful objects, entities, class etc.  javascript would be better
considered an object orientated language, as like .net it concerns itself heavily with objects that maintain state, and your code manipulates this state.

Leave a Reply