javascriptで未定義の変数を参照すると "ReferenceError" が発生する件

javascript 様なら未定義の変数も、undefined にしてくれると思ってた

(function(){
  console.log(a); // undefined
  var a;
  console.log(b); // ReferenceError
})();

その変数が未定義かどうかってどう判別するの?

(function(){
  var a = "test";
  console.log(typeof a == "undefined"); // false
  console.log(typeof b == "undefined"); // true
})();


知らなかった!!