What's fn(data) mean?


#1

In 10.2.2
FormHandler.prototype.addSubmitHandler=function(fn){

console.log(data);
fn(data);
}

function(fn),this fn is a parameter.
but what’s fn(data)mean?it equals what?
thanks for anwsering this question.


#2

I think this gets answered a bit further on, but since I was just working through this thought I’d take a stab at an answer. In formhandler.js on page 219, you add the fn as a callback function to the addSubmitHandler prototype.

In main.js, you actually setup addSubmitHandler to use the following as fn:
myTruck.createOrder.bind(myTruck)

So, when fn(data) is called it’s actually sending back the serialized data to the createOrder function as: myTruck.createOrder(data)

Does that help?

Myrhillion