Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27553
| Path | csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: ! function |
| Date | Thu, 07 May 2015 12:27:55 -0300 |
| Organization | Aioe.org NNTP Server |
| Lines | 31 |
| Message-ID | <mig09m$not$1@speranza.aioe.org> (permalink) |
| References | <ddSdncub_tOuptbInZ2dnUVZ8gidnZ2d@westnet.com.au> |
| NNTP-Posting-Host | YvaHqxzoYrEDLOGsC1Im/w.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com comp.lang.javascript:27553 |
Show key headers only | View raw
On 07/05/2015 07:15, Andrew Poulos wrote:
> I was looking at some "swipe" libraries when I happened upon hammer.js.
> <http://hammerjs.github.io/dist/hammer.min.js>
>
> I've no idea yet as to its quality but the very first line begins with
>
> ! function(a, b, c, d) {
>
> What's the reason behind starting with an exclamation mark?
An Immediately-Invoked Function Expression (IIFE) is usually written as:
(function() { /* etc. */ })();
Or:
(function() { /* etc. */ }()); // Douglas Crockford's preference.
But we can use unary operators instead of the wrapping parentheses too,
if we don't care about the return value of the IIFE:
+function() { /*...*/ }();
!function() { /*...*/ }();
-function() { /*...*/ }();
~function() { /*...*/ }();
Even the void operator can be used:
void function () { /*...*/ }();
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
! function Andrew Poulos <ap_prog@hotmail.com> - 2015-05-07 20:15 +1000
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-07 13:04 +0200
Re: ! function "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-07 05:02 -0700
Re: ! function Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-05-07 12:27 -0300
Re: ! function JJ <jj4public@vfemail.net> - 2015-05-08 00:09 +0700
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-07 21:07 +0200
Re: ! function "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-07 21:31 +0200
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-07 22:20 +0200
Re: ! function "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-07 23:27 +0200
Re: ! function "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-08 00:26 +0200
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-08 11:00 +0200
Re: ! function James Lewis <lewisje@gmail.com> - 2015-06-05 09:10 -0700
Re: ! function Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-18 13:31 -0700
Re: ! function "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-19 01:39 +0200
Re: ! function Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-19 05:48 -0700
Re: ! function Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-05-07 17:47 -0300
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-07 23:22 +0200
Re: ! function Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-05-07 19:08 -0300
Re: ! function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-08 12:08 +0200
csiph-web