IIFE (v5)

Revision 5 of this benchmark created by eshinn 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 bar ( _foo ) {
}( foo ));
ready
dogballs
(function bar ( _foo ) {
})( foo );
ready
void
void function bar ( _foo ) {
}( foo );
ready
new
new function bar ( _foo ) {
}( foo );
ready
bang
!function bar ( _foo ) {
}( foo );
ready
tilde
~function bar ( _foo ) {
}( foo );
ready
void + dogballs
void (function bar ( _foo ) {
})( foo );
ready
void + crockford
(void function bar ( _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