Js grammar problem

  node.js, question

var a = 5;
function woot () {

Log ((a = = 5) plus' 1');
 
 var a = 6;
 
 function test () {
 Log ((a = = 6) plus' 2');
 bracket
 
 test();

};

woot();

Why is the output of this code false1 and why is the value of A the first output statement of undefined. I don’t know whether it is the environment of the browser or the environment of node, There is No Sexual Rapport.

This problem involves an important concept of js, variable promotion.
For variables declared in scope inside, the declaration of the variable will be promoted to the top of the acting, and the assignment of the variable will remain in place.
In woot’s method of inside, js actually parses like this:

var a;
 Log ((a = = 5) plus' 1');
 
 a = 6;
 
 function test () {
 Log ((a = = 6) plus' 2');
 bracket
 
 test();