1

I had look at this question to know about what this means.

(function($) {

})(jQuery);

I am looking at different bootstrap plugins, which have +function ($), while defining the function.

What does + does here, does it appends this function to other functions ?

bhansa
  • 6,166
  • 2
  • 23
  • 42

2 Answers2

2

To guide the javascript parser, that the thing written near the unary operator + is an expression.

EDIT: You can create javascript functions anonymously. This is one of the syntaxes to create the same. By doing so, when they are called (i.e evaluated), they act like a returning a function value. You can read more from the second link which provides a good description of it.

This link explains it well

Once declared, if not named, these can be executed inline like IIFE (Immediately invoked function expressions) as well. And in this form, they can then be used to create plugins or used as namespaces and attached to window object or jquery object for use later.

Good sample file to see anonymous function code in action

http://www.programering.com/a/MTMwITMwATk.html

Amit Kumar Singh
  • 4,083
  • 2
  • 6
  • 22
1

It's a bang function

the + operator is faster than usual !

see more at javascript function leading bang ! syntax

Simone Sanfratello
  • 1,370
  • 1
  • 9
  • 19