<script src="js/script.js"></script>
<script src="js/script1.js"></script>
<script src="js/script2.js"></script>
function scope
function scopeTest(){
var is = true;
if(is){
var is = false;
}
for(var i=0; i<=5; i++){
var inFor = i;
}
console.log(inFor); // 출력되는 값은?
console.log(is);
}
var es = [];
for(var i=0; i<10; i++){
es[i] = function(){
console.log("ECMAScript is ES" + i);
};
}
es[6](); // 출력되는 값은?
var es = [];
for(var i=0; i<10; i++){
(function(i){
es[i] = function(){
console.log("ECMAScript is ES" + i);
};
})(i);
}
es[6]();
block scope
var es = [];
for(let i=0; i<10; i++){
es[i] = function(){
console.log("ECMAScript is ES" + i);
};
}
es[6]();