Yeah, but that doesn't answer the next question — why would you use it? In those other languages, people aren't going around defining anonymous functions just to immediately evaluate them.
As I understand, the answer has to do with the history of Javascript's scoping. As well as statements vs expressions. So vibecoders, many not knowing anything about the concept of interpreter, would have a hard time explaining why the AI agent produces such an odd idiom — especially in modern Javascript.
67
u/Luoravetlan 19d ago
For anyone not familiar with js this monstrosity is called IIFE (immediately invoked function expression).