DEV Community

Discussion on: The Empty Statement in JavaScript

Collapse
 
hi_artem profile image
Artem

Actually empty statements in js can have some legitimate use cases. For example, to prevent undesired behavior in IIFE you sometime want to prefix it with empty statement, like so:

;(()=>console.log('ooof'))()
Collapse
 
bhagatparwinder profile image
Parwinder πŸ‘¨πŸ»β€πŸ’» • Edited

Ah thanks! Figured out when and what sort of undesirable behavior. If we are concatenating two JS files it could definitely cause issues. Here’s a write up with an example:

mariusschulz.com/articles/disassem...

Collapse
 
hi_artem profile image
Artem

Sure, and my bad, I should have specified it in the original post!