DEV Community

Discussion on: Should you use semicolons in JavaScript?

Collapse
 
lexlohr profile image
Alex Lohr

There's a worse issue with omitting semicolons; consider the following code:

(() => { console.log('first') })()
(() => { console.log('second') })()
Enter fullscreen mode Exit fullscreen mode

This will throw a TypeError that undefined is not a function, because the brackets around the second IEFE are interpreted as a function call. A semicolon between these lines will solve the issue.

Collapse
 
frankwisniewski profile image
Frank Wisniewski

mmh.... what is an IEFE?

Collapse
 
lexlohr profile image
Alex Lohr

Immediately executed function expression.

Thread Thread
 
frankwisniewski profile image
Frank Wisniewski

aha, I've only encountered IIFE so far...
(immediately invoked function expression)
I think we mean the same thing