The reason why function () {} () reported an error is that it was reported wrong at the pre-compilation stage? Or do you report an error only when you execute ()? Ask for advice.

is confused about why the function expression IIFE,function () {} (); reported an error immediately.
ask whether the error is reported at the precompilation stage or during the execution of ().
js interprets the function declaration in the "precompilation" phase, but ignores the expression
1. One is to report an error in the precompilation stage, because the precompilation will declare a function, with a missing name and throw a syntax error message, because the function declaration requires a name.
2. Error is reported only when (); is executed. Since function () {/ / code} has been explained in the "precompilation" phase, js will skip function () {/ / code} and try to execute ();, so it will report an error

Nov.12,2021

syntax error is a compilation time error;

Logic error is executing Times error;

Menu