Linked Questions

44 votes
4 answers
2k views

var ninja = (function(){ function Ninja(){}; return new Ninja(); })(); Why is the function above encapsulated in parentheses and why is there a (); at the end? I think it's a constructor ...
Sangram Singh's user avatar
3 votes
3 answers
655 views

I was solving a puzzle on JS and I found this code: var xx = (function () { var e = 0; return function () { return e++ } })(); It was asked what will be the value of xx. I've googled about ...
Bharat Soni's user avatar
  • 2,902
3 votes
2 answers
185 views

Possible Duplicate: How does an anonymous function in JavaScript work? What does this JavaScript snippet mean? I use in my scripts: (function(){ ...[code].. })() I can't find documentation ...
fpilee's user avatar
  • 2,118
-4 votes
2 answers
193 views

How does this structure work when the function is anonymous? !function() { . . . }();
Tim's user avatar
  • 8,990
2 votes
1 answer
161 views

i see the following code in a lot of java-script files. (function () { //code goes here })(); Can somebody explain this, or point me to a tutorial that explains this?
voilbak's user avatar
  • 31
-1 votes
1 answer
122 views

How it is work? function(){...}(); I can't understand what's going on. I think this is javascript not node.js puzzle. But I can not find solution. fs.readdir(filesDir, function(err, files) { if (err)...
user2972298's user avatar
0 votes
0 answers
83 views

I have these few lines of code: (function(exports){ // Do something })(typeof exports===typeof {}&&exports===this?exports:this.webdriver=this.webdriver||{}) What does this mean? How can I ...
user1607549's user avatar
  • 1,569
1 vote
0 answers
30 views

What is - if there is any - the difference between these two pieces of code: (function(){ // code }); AND (function(){ // code })();
yossi's user avatar
  • 3,174
1082 votes
29 answers
651k views

How do I create a namespace in JavaScript so that my objects and functions aren't overwritten by other same-named objects and functions? I've used the following: if (Foo == null || typeof(Foo) != "...
Scott McKenzie's user avatar
322 votes
7 answers
136k views

In the YUI library examples, you can find many uses of this construct: (function() { var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, layout = null, ... })(); I think the last ...
user54692's user avatar
  • 3,237
44 votes
11 answers
129k views

How do I make an infinite loop in JavaScript? I'm trying to make a slideshow, which I have working, but I can't get it to loop. I can't even get it to loop twice. The code I'm using right now is ...
JacobTheDev's user avatar
  • 18.7k
65 votes
4 answers
30k views

Possible Duplicates: What is the difference between a function expression vs declaration in JavaScript? Explain JavaScript's encapsulated anonymous function syntax Why this: (function () { ...
lxa's user avatar
  • 3,372
12 votes
4 answers
16k views

I am modifying some code that has a lot of jQuery but I am not sure what some of the jQuery statements are doing. At the top of the jQuery code there is jQuery.noConflict *1. I understand that. But ...
Emily's user avatar
  • 10.1k
50 votes
1 answer
33k views

Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} Declaring functions in JavaScript I've seen 2 different syntaxes for defining functions in ...
CaptainCodeman's user avatar
43 votes
2 answers
40k views

1. function abc(){ alert("named function"); } v/s 2. function(){ alert("Un-Named function"); } Kindly explain from beginners point.
Maxx's user avatar
  • 856

15 30 50 per page
1
2 3 4 5