LoginSignup
19
10

More than 5 years have passed since last update.

【いまさらですが】Javascriptの「undefinded」と「is not define」の違い

Posted at

今更ですが、Javascriptの「undefinded」と「is not define」のエラーの違いについてです。
※以下、コードの実行環境はChromeの開発者ツールを使用しています。

is not define

変数が定義されていないことを指します。
以下のようなパターンです。


console.log(value);
// Uncaught ReferenceError: value is not defined

undefinded

変数は定義されていますが、値が入っていない(初期化されていない)ことを指します。
以下のようなパターンです。

var value;
console.log(value);
// undefined

初期化すると値が出力されます。

var value = null;
console.log(value);
// null
19
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
10