-
-
Save karbassi/401841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// what does this do?: | |
(function(){ | |
var i = 5; | |
}()); | |
// What this does is create an anonymous function then assigns a local variable 'i' | |
// with an integer value of 5 to it. Then it runs the function. | |
(function(){}); // creation of anonymous function | |
(function(){}()); // creation of anonymous function which is then ran. | |
// is it like a javascript hack equivalent to the jQuery(document).ready()? e.g.: | |
$(function() { | |
var i = 5; | |
}); | |
// $(); is short-code for jQuery(document).ready(); Some use this for it's shortness, | |
// but it doesn't give you a no-conflict use of the $ character. This may problems | |
// if your project uses prototype or any other javascript library that uses $. | |
// Good reference: http://api.jquery.com/ready/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PS
then assigns a local variable 'i' with an integer value of 5 to it.
Wow, you are either very verbose, or think I'm a complete javascript n00b. Knowing you, I'm entirely sure it is the verbosity. ^_^