Several ways of turning function declarations into expressions
Here are a variety of ways of writing Immediately Invoked Function Expressions (a.k.a. IIFE's in JavaScript):
var foo = function() {
// Your code in here
}();
var foo = (function() {
// Your code in here
})();
!function() {
// Your code in here
}();
+function() {
// Your code in here
}();
-function() {
// Your code in here
}();
~function() {
// Your code in here
}();
new function() {
// Your code in here
}();
new function(arg) {
// Your code in here
}(arg);
Written by Brian
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Functions
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#