React 입문 2

react 강의

목록 보기
2/2

let, const, var

let blockScopeVariable = "Available only in this block";
// 전역 스코프

if (true) {
    var blockedScope = "Visible inside this block";
    console.log(blockedScope);
  // Visible inside this block
}
console.log(blockedScope);
// Visible inside this block
// var를 사용했을 때는 스코프를 벗어난 것처럼 보이게 된다.

console.log(blockScopeVariable)
// Available only in this block

0개의 댓글