The variable declaration should be at the top of the scope, but the assignment is not.
function Example () {var declaredbutassigned;//as output declaredbutnotassigned undefined Console.log (declaredbutnotassigned) Declaredbutnotassigned = true}
Anonymous expressions can elevate their variable names, but they cannot raise function assignments.
function Example () {console.log (anonymous);//undefined anonymous ();//Type error var anonymous = function () {console.log (' Anonymous function expression ');}}
A named function expression promotes the variable name, not the function name or body of the function.
function Example () {Console.log (AAA);//UNDEFINEDAAA ();//typeerror AAA is not a functionbbb ();//referenceerror BBB are not Definevar AAA = function BBB () {console.log (' hi~~ ')};
When the variable name is the same as the function name Example2 () {Console.log (AAA);//UNDEFINEDAAA ();//typeerrorvar AAA = function named () { Console.log (' Hello ');};}
function declarations promote variable names and function bodies
function Example () {AAA (); function AAA () {console.log (' hi~~ ');}}
"Learning Notes" JavaScript coding specification-declaring elevation