Code Fix

初級ReferenceError: x is not defined の原因と直し方 › パターン2

ReferenceError: x is not defined の原因と直し方

存在しない変数・関数名を参照したときに出るエラーです。

 1  function square(n) {
 2    return n * n;
 3  }
 4  console.log(______(4));
                   ^
main.js:4 console.log(squre(4)); ^ ReferenceError: squre is not defined

空欄を埋めて実行を通す

広告
広告スロット(未設定)

ReferenceError: x is not defined の原因と直し方

タイプミスだけでなく、let/constのブロックスコープの外から参照した場合にも同じエラーになります。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)