• Function
function greetSomeone(firstName) {
  var time = 'night';
  if (time === 'night') {
    var greeting = 'Good Night';
  }
  return greeting + ' ' + firstName; 
}
greetSomeone('Steve'); // Good Night Steve
  • Block
function greetSomeone(firstName) {
  let time = 'night';
  if (time === 'night') {
    let greeting = 'Good Night';
  }
  return greeting + ' ' + firstName; 
}
greetSomeone('Steve'); // ReferenceError

코드 출처: 코드스테이츠(CodeStates)

0개의 댓글