I was wondering. If this -> (function(){...})()
is an IIF ( Instantly Invoked Function ) then what does a function like this do -> !function(){...}
Asked
Active
Viewed 38 times
0
-
In short: the same. There are different ways to write an IIFE. – Sirko Nov 04 '20 at 07:31
-
`!function(){...}()` (note the final `()`) is another way to write a IIFE as is `+function() {}()` – Jaromanda X Nov 04 '20 at 07:31
-
So I can write in both ways, correct? – Nov 04 '20 at 07:31
-
yes, of course, it's just another notation for effectively the same thing – Jaromanda X Nov 04 '20 at 07:32
-
Ok thanks! I see someone found an existing post – Nov 04 '20 at 07:33
-
you'll often see `;(function(){...})()` as well ... extra `;` aren't a problem in javascript, but a "missing" one can lead to unexpected results – Jaromanda X Nov 04 '20 at 07:35
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224079/discussion-between-user39051323-and-jaromanda-x). – Nov 04 '20 at 07:41