0

At the beginning of the bootstrap.js code file they have this

!function($) {

what does it mean?

Peter
  • 7,792
  • 9
  • 63
  • 94
  • 4
    possible duplicate of [What does the exclamation mark do before the function?](http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function) – DCoder May 29 '12 at 04:16
  • 1
    http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function – Jhong May 29 '12 at 04:16
  • Yeah it looks like it is a copy of that question – Peter May 29 '12 at 04:45

1 Answers1

2

If you code this: function something() {something}, it's a declaration of a function, but it does not invoke the function (you'd have to run something() later on).

So, to actually invoke the function, you need to do something like (function(){})(); ... "!function($) {}" is sort of an alternative to the wrapping the entire function in parens. The exclamation mark syntax is a shortcut to writing that. "!" turns the line into an expression that returns true.

Michael Manoochehri
  • 7,931
  • 6
  • 33
  • 47