datasetCSR
is a variable that when declared executes and receives the return value of the method execECM
.
Considering the definition of the object as:
var obj = {
execECM: function ( callback )
{
// será passado como argumento para esse método
// uma função como callback
// você poderá invocá-la a qualquer momento dentro do contexto
// de execECM
return callback() + 5;
},
myCustomFunction: function ( value )
{
// declarando datasetCSR e associando seu valor ao valor de retorno
// do método execECM
var
datasetCSR = this.execECM( function () {
return value;
} );
console.log( datasetCSR );
}
};
The method execECM
receives a function such as callback to use at some point in the scope of your declaration.
A callback Function, also known as a Higher-order Function, is a Function that is passed to Another Function (Let’s call this other Function "otherFunction") as a Parameter, and the callback Function is called (or executed) Inside the otherFunction.
Understand Javascript Callback Functions and Use Them
Using the previously declared object, we will have:
obj.myCustomFunction( 10 ); // 15
obj.myCustomFunction( 1 ); // 6
obj.execECM( 10 ) // Uncaught TypeError: callback is not a function(…)
var calls = function ()
{
return 100;
};
obj.execECM( calls ); // 105
Is this what you want to know? http://answall.com/q/9936/101
– Maniero
I’m not quite sure what you ask in the question. Now
this.execECM
is a function. What do you want to know? aboutthis.execECM
or the function that is passed to you as an argument? You can explain your question better?– Sergio
I would like to understand the logic of this function creation mode. execECM is a function yes. What I don’t understand is what is happening. datasetCSR is a function that when executed it calls the exeECM function?
– durtto