ReferenceError: "x" is not defined
Cause of Error:
There is a non-existent variable that is referenced somewhere in the script. That variable has to be declared, or make sure the variable is available in the current script or scope.
Example 1: In this example, the variable(val1) is being accessed from the outside of the function, So the error has not occurred.
ReferenceError: 'val1' is not defined
Example 2: In this example, the variable(GFG) is not defined, So the error has occurred.
ReferenceError: 'GFG' is not defined