Hello there guys, back to me Left, your all-time favorite coder in the forum. N'ah, I'm just kidding, don't get it too seriously.
Here, in my first tutorial, I will explain all about wrapper function, what is wrapper function, wrapper function is a function itself. Here I'll put some examples.
The code above is the example of a simple wrapper function, I didn't write the entire code as we didn't really need it for this time.
The code above is also named with 'wrapper function', even if there's a variable declared within it. For variable-wrapper-function-declaring, we have to add the ';' symbol in the end of the code to close the function. We didn't have to give the function a name, since it's already named with the variable. So the function below was named 'check'.
This is a very small tutorial to explain the simplest thing ever in JS, wrapper function. Hope you did understand it correctly. If you didn't understand this, you can just ask in this tutorial -- don't hesitate to ask.
Here, in my first tutorial, I will explain all about wrapper function, what is wrapper function, wrapper function is a function itself. Here I'll put some examples.
- Code:
function firstFunc(param, callback) {
if( param ) {
callback.call(some callback);
}
}
The code above is the example of a simple wrapper function, I didn't write the entire code as we didn't really need it for this time.
- Code:
var check = function(id,callback) {
if(id===undefined) {
callback.call(id,check);
}else{
calback.call(bla bla bla);
}
};
The code above is also named with 'wrapper function', even if there's a variable declared within it. For variable-wrapper-function-declaring, we have to add the ';' symbol in the end of the code to close the function. We didn't have to give the function a name, since it's already named with the variable. So the function below was named 'check'.
This is a very small tutorial to explain the simplest thing ever in JS, wrapper function. Hope you did understand it correctly. If you didn't understand this, you can just ask in this tutorial -- don't hesitate to ask.