pdct5w
Last Updated: February 25, 2016
·
334
· bhousman
9b51c0db928eefd139d71297e5893a2e

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);
Say Thanks
Respond