IIFE (v3)

Revision 3 of this benchmark created by Anders Ringqvist on


Description

Immediately-Invoked Function Expression (IIFE)

http://benalman.com/news/2010/11/immediately-invoked-function-expression/

Note that it´s only with Crockford and dogballs you can define what should be returned from the IIFE.

  • void will always return undefined.
  • new will always return object.
  • bang will always return false.

Tilde is a different beast all in it´s own.

It´s recommended to go with either Crockford or dogballs as they are the most portable and conventional.

Setup

var foo = 'foo';

Test runner

Ready to run.

Testing in
TestOps/sec
Crockford
(function ( _foo ) {
}( foo ));
ready
dogballs
(function ( _foo ) {
})( foo );
ready
void
void function ( _foo ) {
}( foo );
ready
new
new function ( _foo ) {
}( foo );
ready
bang
!function( _foo ) {
}( foo );
ready
tilde
~function( _foo ) {
}( foo );
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by satyr on
  • Revision 3: published by Anders Ringqvist on
  • Revision 4: published on
  • Revision 5: published by eshinn on