---
title: "Comment by Nhut nguyen minh on \"Upcoming Interesting JavaScript ES2021 (ES12) Features to Look for\" | Hashnode"
description: "I have a question : why Semicolon before arrow IIFE ??? ;(() =&gt; {})() ."
url: "https://hashnode.com/posts/upcoming-interesting-javascript-es2021-es12-features-to-look-for-1/6055db305f8d512169726a2d/comment/605a266c47b0d2243d4aaef2"
---

[Discussion](https://hashnode.com/posts/upcoming-interesting-javascript-es2021-es12-features-to-look-for-1/6055db305f8d512169726a2d)

Comment [Upcoming Interesting JavaScript ES2021 (ES12) Features to Look for](https://hashnode.com/posts/upcoming-interesting-javascript-es2021-es12-features-to-look-for-1/6055db305f8d512169726a2d)

[Nhut nguyen minh](https://hashnode.com/@devNhut)

[Mar 23, 2021](https://hashnode.com/posts/upcoming-interesting-javascript-es2021-es12-features-to-look-for-1/6055db305f8d512169726a2d/comment/605a266c47b0d2243d4aaef2)

I have a question : why Semicolon before arrow IIFE ??? ;(() => {})() .

[Adarsh Hegde](https://hashnode.com/@adarshhegde)

[Mar 24, 2021](https://hashnode.com/posts/upcoming-interesting-javascript-es2021-es12-features-to-look-for-1/6055db305f8d512169726a2d/comment/605a266c47b0d2243d4aaef2#reply-605b9c3b78c4742436d5007c)

its to prevent the IIFE opening and closing parenthesis to act as a function call for the previous statement which will throw an error let statement\_1 = () => console.log("whatever");

statement\_1()

(() => { console.log("haha") })()

this will throw an error, statement\_1(...) is not a function

but you might say it is a function, so why the error?

statement\_1() // this statement executes that anonymous function, and returns nothing,

and the opening and closing ( parenthesis ) of the IIFE will make it look like its a function call for the return value of the above statement so it will actually look like

statement\_1()( ()=>{ .. } )() // the outer IIFE parenthesis is now acting as function call syntax for return value of statement\_1()

so it'll try to call the returned value from statement\_1() as a function, so it will cause all loads of bugs and errors, to fix this we manually state the end of the first statement with a semicolon, this way the JavaScript engine doesn't get confused and can differentiate between the two statements properly

statement\_1();

( () => {}) ()

TL;DR use semicolons more often.

in the post they just placed the semicolon at the beginning of the IIFE rather than end of first statement.
