0

Last I meet

!function () {
   function a() {
      some code here . . .
   }    
} ();

I know that "!" similar "not" negative particle, Everything work fine in this function, but I want know why in this case are used this "!" ??

THANKS!

ChiranjeeviIT
  • 529
  • 1
  • 4
  • 17

1 Answers1

0

It's an immediately-invoked function expression. Instead of (function(){})(); you can save a few bytes by using a unary operator: !function(){}();, ~function(){}(); etc...

An immediately-invoked function expression – IIFE for short – is as the name suggests a function that is immediately invoked. Read more at Ben Alman

Phillip
  • 6,033
  • 3
  • 24
  • 34