1

In the following code I know adding () at the end of the Function makes it a self invoking function.

However I don't understand if passing "socialMedia" which is an object is being passed as a parameter or for some other reason.

var social = function(){

}(socialMedia);
Yama
  • 17
  • 1
  • because it is than available as an argument to the method and you can reference it. Most libraries will do this so you can alias the varaible and not have to reference the original name. – epascarello Nov 02 '16 at 12:45
  • http://www.w3schools.com/js/ – Sumit Maingi Nov 02 '16 at 12:45
  • If its being passed to a function, *by definition* its a parameter. –  Nov 02 '16 at 12:46
  • 2
    You seem to understand that its calling the function with a single argument `socialMedia`. So, what difficulty are you having? –  Nov 02 '16 at 12:48
  • 5
    @SumitMaingi w3schools is terrible, use something else. – ASDFGerte Nov 02 '16 at 12:48
  • I agree with @ASDFGerte - [mdn](https://developer.mozilla.org/nl/) provides way better information and gets updated regularly. – Kevin Nov 02 '16 at 13:08

1 Answers1

0

You are calling the function by passing the value. Have a look at the below code:

var add = function(val){alert(val)}(100);

This would trigger the add function with val assigned to 100.

Thalaivar
  • 23,282
  • 5
  • 60
  • 71