Linked Questions

87 votes
6 answers
9k views

In JavaScript, what is the advantage of !function(){}() over (function () {})()? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I've long used the following for self-executing, anonymous functions in JavaScript: (function () { /* magic happens */ }...
Andrew Hedges's user avatar
73 votes
4 answers
72k views

Javascript anonymous function call [duplicate]

I was reading JS sources from Twitter — on my way to improve my JS knowledge base, when I came across the strange way of calling anonymous function: !function( $ ) { ... }( window.jQuery ); ...
Konstantin Likhter's user avatar
37 votes
3 answers
15k views

! preceding function in javascript? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I saw a function formatted like this today for the first time: !function(){}(); What is the preceding exclamation mark ...
rg88's user avatar
  • 20.8k
34 votes
2 answers
9k views

Why use NOT operator on anonymous function call? (a la Knockout 2.1.0) [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? If you look at the source code for KnockoutJS 2.1.0 you will see a code structure like this start on line 7: !function(...
CgodLEY's user avatar
  • 994
25 votes
3 answers
11k views

what does !function in Javascript mean? [duplicate]

Sorry for posting this but !function is not google-able and I did not find it in my JavaScript code. Here is how Twitter uses it: <a href="https://twitter.com/share" class="twitter-share-button" ...
Barka's user avatar
  • 8,832
18 votes
2 answers
2k views

How exactly does !function(){}() work? [duplicate]

I've seen: !function(){ //code }(); Used in several places to immediately execute an anonymous function. Normally, it's used in lieu of: (function(){ //code }()) Anyone know how the ! actually ...
thedz's user avatar
  • 5,524
7 votes
2 answers
891 views

JavaScript !function(){} [duplicate]

when looking at the minified Sizzle code, I noticed that it begins like this: !function(a){//... }(window) Why is there an exclamation point at the beginning? I thought that ! was the not ...
Progo's user avatar
  • 3,482
5 votes
2 answers
296 views

strange anonymous javascript function call [duplicate]

I was looking at this very cool snippet and i came across this weird line in the js and deleting that prevent the function from being invoked !+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+! ...
MimiEAM's user avatar
  • 2,620
5 votes
1 answer
2k views

What is !function in javascript? [duplicate]

I have this code in google tag manager: <!-- Facebook Pixel Code --> <script> !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n....
Leon Segal's user avatar
4 votes
1 answer
1k views

negating self invoking function? !function ($) { ... }(window.jQuery); [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I was looking through the Twitter Bootstrap JavaScript code and I noticed all their plugins are wrapped in negating self ...
Hailwood's user avatar
  • 91k
3 votes
1 answer
812 views

what is the meaning of "!function($){}(window.jQuery)"? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? What does !function ($) { $(function(){ }) }(window.jQuery) do? what is the meaning of "!function($){}(window.jQuery)" ...
linjuming's user avatar
  • 2,147
5 votes
2 answers
147 views

Is this jQuery related, and what does this mean? [duplicate]

I have been searching, but no clues... or I haven't search the proper way (so please excuse me if duplicate) Does the following code, mean: If there is no jQuery defined, or no document ready? !...
Alex's user avatar
  • 7,648
2 votes
5 answers
175 views

What is "!functionname()"? [duplicate]

I was looking for some example code for JS, and I found something that used !function() and I was wondering what exactly is the exclamation for?
Sean's user avatar
  • 8,601
1 vote
1 answer
503 views

What is this javascript syntax? !function(){} [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I came across this today and have never seen before: !function($) { //contents removed }( window.jQuery ); I am ...
Itumac's user avatar
  • 645
5 votes
2 answers
85 views

What is the purpose of declaring a function like !function(){ code }(); [duplicate]

What is the purpose of declaring a function like: !function(){ code }(); Why the !?
GoTo's user avatar
  • 6,370
4 votes
2 answers
191 views

Why does this Twitter script tag try to evaluate to true? Does it matter? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I'm maintaining an existing site with a "tweet" button, which appears to come from this page A colleague here brought ...
Chris Trahey's user avatar
  • 18.3k
1 vote
2 answers
459 views

JS: What's the difference between a ! closure and () closure? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? So I was going back and looking over some of my own code as well as some other javascript code and I realized that a ...
kd3v's user avatar
  • 21
1 vote
1 answer
128 views

What is the purpose of using negation before function declaration? [duplicate]

In twitter bootstrap source code I found the following: !function ($) { "use strict"; // jshint ;_; I've never met such a construction before. What does it mean? It looks like IIFE, but I am not ...
paperstreet7's user avatar
  • 2,148
3 votes
0 answers
477 views

What does the Javascript !function declaration syntax do? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I ran across a function definition style that is new to me while browsing the Emile animation library: !function () { ...
Gordon's user avatar
  • 71
1 vote
1 answer
271 views

What does "!function () {}" mean/do in javascript? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? ! preceding function in javascript? javascript function leading bang ! syntax I've been seeing this pattern a little ...
hellatan's user avatar
  • 3,527
0 votes
1 answer
173 views

! character before Self-Invoking Anonymous Function [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I;ve just came across a tablesorter plugin, and while looking at the source, I found that plugin is set up with Self-...
dragonfly's user avatar
  • 17.6k
0 votes
2 answers
213 views

what's mean: !function in javascript? [duplicate]

I have a simple question. I've found this code, and i don't know this statement !function ($) { // (...) }(window.jQuery); why put ! before a function? i've found this on bootstrap.js file,...
Paulo Mendonça's user avatar
3 votes
2 answers
97 views

what does !function() means in Javascript? [duplicate]

I can read and write some JavaScript, but today I came across a .js file starting with !function() { /* code here */ }.call(window); Question what does ! infront of function means?
daydreamer's user avatar
  • 89.4k
1 vote
1 answer
122 views

What does the ! part of !function(){...}(); mean? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? So I've come across the use of the following by the twitter share button code: !function (d, s, id) { var js, fjs = ...
Samuel Parkinson's user avatar
1 vote
1 answer
172 views

what does `!function()` mean? [duplicate]

I'm using a nice bundle that integrates Bootstrap with Symfony. It contains some javascript for dealing with form field collections. When I was looking at the code to see how they did it I ran across ...
dnagirl's user avatar
  • 20.3k
0 votes
2 answers
97 views

How is this working !function(){console.log("hi")}() [duplicate]

I read this on the javascript garden site. Can someone explain how it works? !function(){console.log("hi")}()
user566245's user avatar
  • 4,139
1 vote
2 answers
78 views

javascript self executing syntax [duplicate]

Did anyone know the code which define like this: !function(window, undefined) { // do something } (window) By searching in google, I can understand the syntax like: function(window, undefined) {...
Leonhart 27's user avatar
1 vote
1 answer
125 views

Why create an anonymous function with a ! before it? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? What's the point of the ! in the snippet bellow? !function ($) { // code }(window.jQuery); This syntax is used ...
srcspider's user avatar
  • 11.1k
-1 votes
2 answers
69 views

Self Invoking Functions [duplicate]

Importance of using ! in this code var testValue; !function test() { testValue = 3; }(); console.log(testValue);
Mohamed Elshahawy's user avatar
3 votes
2 answers
72 views

How to setup variable to point to global object – independent of context execution? [duplicate]

Can someone please explain to me what the heck does this mean? !function (global, moduleDefinition) { 'use strict'; var dependencies = []; if (typeof define === 'function' && define....
Youssef's user avatar
  • 300
1 vote
0 answers
119 views

!function in Javascript [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? I am looking at the bootstrap Javascript provided by the Bootstrap, from Twitter. And the first thing I notice in the ...
Moon's user avatar
  • 34.3k
0 votes
1 answer
79 views

What does this jQuery function mean? [duplicate]

I am trying to understand how a js library works, more specifically http://toopay.github.io/bootstrap-markdown/. The whole js file is wrapped in this function: !function ($) { }(window.jQuery); ...
Vlad Otrocol's user avatar
  • 3,092
2 votes
0 answers
98 views

What does !function (name, definition) means in javascript? [duplicate]

Possible Duplicate: What does the exclamation mark do before the function? So the start of the morpheus script has this: !function (name, definition) { if (typeof define == 'function') define(...
CamelCamelCamel's user avatar
2 votes
1 answer
55 views

what does this mean? !function() [duplicate]

What does this mean? !function a(){ }({ x: [function(){alert(2);}] }) When I reading some codes in a chrome extension, I have found this block of code. I am confused how this should work.
ass-king some questions's user avatar
2 votes
1 answer
57 views

(function(){})() vs. !function(){}() [duplicate]

In jQuery javascript code I see (function(window, undefined) { })(window); And in Twitter !function(window, undefined) { }(window); Can someone tell what the difference between these two ...
Albert Bakker's user avatar
4 votes
0 answers
69 views

Came across a convention I've never seen. What does it do? !function [duplicate]

I was just being goofy and analyzing some code in the source of some sites and I ran across this convention for an anonymous function. !function(window){ //so a bunch of stuff }(this) I have ...
james emanon's user avatar
  • 11.5k
1 vote
0 answers
59 views

Javascript !function () {} notation [duplicate]

I've seen several times function like this !function(self) { // code }(this) what means !function ?
user3260664's user avatar
0 votes
0 answers
57 views

What is the meaning of `! function(...) {...} (...);`? [duplicate]

I get confused by this function: ! function(e, t, n, c, r, a, i) { e.Newsletter2GoTrackingObject = r, e[r] = e[r] || function() { (e[r].q = e[r].q || []) .push(arguments); }, ...
Black's user avatar
  • 19.1k
1 vote
0 answers
52 views

What does the bitwise operator do before a function in Javascript? [duplicate]

I have seen the bitwise operator used in a self calling function, see below example, so I have a simple question, what does it do? ~(function() { alert("Hello World"); })();
Ben Osborne's user avatar
0 votes
0 answers
43 views

What does this syntax (!function (e)) in the beginning of Loading Overflow JQuery plugin mean? [duplicate]

So I was just reading the code of Loading Overlay plugin for jquery. At the beginning, I can see the following line of code. ! function(e) { "function" == typeof define && define.amd ? define(...
himanshu's user avatar
  • 125
0 votes
0 answers
42 views

How to call Functions starting with "!" [duplicate]

I saw a function in a file, Something like this.. ! function(e) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = e(); else if ("function" == typeof ...
Hardeep Mehta's user avatar
0 votes
0 answers
41 views

In moment.js, what's the meaning and the use of wrapping script in !function() [duplicate]

EDIT : This question was marked as duplicate, which is quite unfair.I acknowledge that this question about the question mark answers a part of the question. But the following is still mysterious to me....
CharlYox's user avatar
0 votes
0 answers
41 views

!function in javascript, what does it mean? [duplicate]

I see this syntax of fb pixel code: !function(...){ // code }(...); I don't know what is this syntax to do, can anyone tell me?
Văn Quyết's user avatar
  • 2,442
1 vote
0 answers
38 views

Why use `!function()` declarations? [duplicate]

In core.js you'll find lots of function declerations like the following: !function(undefined){ var __e = null, __g = null; // more code } Or this one: !function(){ try { var iter = [1]...
oligofren's user avatar
  • 21.8k
0 votes
0 answers
38 views

What does the "!" symbol at the start of the function do in JS? [duplicate]

I was wondering. If this -> (function(){...})() is an IIF ( Instantly Invoked Function ) then what does a function like this do -> !function(){...}
user avatar
0 votes
1 answer
37 views

Javascript !function(){}?? What is it mean? [duplicate]

Last I meet !function () { function a() { some code here . . . } } (); I know that "!" similar "not" negative particle, Everything work fine in this function, but I want know why in ...
Rafayel Armeni's user avatar
1 vote
0 answers
35 views

what do 'void,+,-,~,!' in front of function do? [duplicate]

From this https://en.wikipedia.org/wiki/Immediately_invoked_function_expression !function () { /* ... */ }(); ~function () { /* ... */ }(); -function () { /* ... */ }(); +function () { /* ... */ }...
Ds Klur's user avatar
  • 103
1 vote
0 answers
33 views

Why do most Javascript libraries append the not operator to their IIFEs? [duplicate]

I've noticed that most/very close to all Javascript libraries (jQuery, require, moment and loads more) append their IIFE with the not operator (!). Could someone explain why this is done, and the ...
user avatar
0 votes
0 answers
33 views

Closures or ! for self-inoking functions [duplicate]

While studying the closers topic I stack up with one simple question. For example these code work: !function (){ console.log(true) }(); (function (){ console.log(true) })(); // doesn't ...
Adrian's user avatar
  • 273
1 vote
0 answers
33 views

Javascript !function [duplicate]

I use jQuery-UI for an application. This Application uses drag and drop and for mobile support i use jQuery UI Touch Punch. I was wondering why the function look like this: !function (a) { //code ...
Pablo Christiano's user avatar

15 30 50 per page