ES6. 1

Austin Jiuk Kim·2022년 4월 7일
0

JavaScript

목록 보기
2/6

1. Variable

JavaScript supports var, let, const to define variables.

However, you had better not to use var.

The reason is that

  • var is restricted by the scope.
  • var does not arise error even defined twice

So, you should use let instead of var for rewritable variables. And you should use const for constant variables.

var hello = 'hello'

if (true) {
  var hello = 'world'
  console.log(hello)
}

console.log(hello)
profile
그냥 돼지

0개의 댓글