3 ms·
There is a reason why that issue with IIFEs can be hit, and it's because you've omitted some semicolons - granted they are the sort that most people omit. Sinc
by munk-a 8y ago
There is a reason why that issue with IIFEs can be hit, and it's because you've omitted some semicolons - granted they are the sort that most people omit.
Since everything in js is a statement the correct semi-colon syntax for the above is
function hasSemicolons() {
console.log('hello world');
};
(function() {
console.log('this is broken, JS will call hasSemicolons()');
})();
- recursive 8y agoThe ECMAScript specification (https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf https://www.ecma-international.org/publications/files/ECMA-S...) has statements in a separate chapter from function declarations. (Chapter 14) Furthermore, the function declaration grammar does not contain a semi-colon, unlike other statements.