Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The question have error.

You need to call `foo()` before the first `console.log` to get that behavior.

  function foo() {
      let a = b = 0
      a++
      return a
   }
 foo()     // <------ INSERT THIS
  console.log(typeof a)
  console.log(typeof b)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: