LOLWesta, a social media forum


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
[#1] Wrapper Function Empty [#1] Wrapper Function Wed Mar 04, 2015 7:30 am

Left


Members
Members
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.

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.

2
[#1] Wrapper Function Empty Re: [#1] Wrapper Function Wed Mar 04, 2015 8:01 am

Tsu


Members
Members
First of all, welcome LOLWesta's new coder, Left.

Are you sure you'll understanding .call(); so deeply?

3
[#1] Wrapper Function Empty Re: [#1] Wrapper Function Fri Mar 06, 2015 9:26 am

LOLWesta


LOLWesta King
^ lol.. this is not the core of the tutorial, he's just showing an example.

https://lolwesta.forumotion.com

4
[#1] Wrapper Function Empty Re: [#1] Wrapper Function Tue Apr 07, 2015 8:25 am

Left


Members
Members
The webmaster's absolutely true. I just write a little bit of example, so a complicated code won't help, unless if I write a reference for an existing methods.

Sponsored content


View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum