[Prototype-core] Javascript closures
Can anyone tell me the difference between the following (or a better place to ask this question) 1) var myVar = function(args){ // inner functions and vars }; 2) var myVar = (function(args){ // inner functions and vars }); 3) var myVar = (function(args){ return { inner functions and vars })(); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Javascript closures question
Can anyone explain the difference in the folllowing and when and why to use each of the methods. (Or knows a better place to ask this question) 1) var myVar = function(args){ // inner functions and vars }; 2) var myVar = (function(args){ // inner functions and vars }); 3) var myVar = (function(args){ return { //inner functions and vars } })(); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Javascript closures
Can anyone tell me the difference between the following (or a better place to ask this question) 1) var myVar = function(args){ // inner functions and vars }; 2) var myVar = (function(args){ // inner functions and vars }); 3) var myVar = (function(args){ return { //inner functions and vars } })(); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---