Variable Access to Closures in js Cycles

  node.js, question
var str = "abcdefgabcdefg"
 for(var i = 0;  i<str.length;  I plus)
 (function(i){
 var str = str;
 console.log(str)
 })(i)
 bracket
 
 
 //-> all are under found

There is an error in the answer. IIFE here will not block scope chain, but will instead extend scope chain. IIFE also has access to the superior scope.
As for why undefined, it is because var str = str; Statement. Str variables are hosting to the top of the current scope in javascript engine parsing

(function(i){
 var str = str;
 })

Equivalent

(function(i){
 var str;
 str = str;
 })

Here is a detailed article.
Javascript variable promotion

As the answer says
 Your code is equivalent to
 var str = "abcdefgabcdefg"
 for(var i = 0;  i<str.length;  I plus)
 (function(i){
 var str;
 str = str;
 console.log(str);
 })(i)
 bracket