ReferenceError 类
- 继承自: <errors.Error>
表示正在尝试访问未定义的变量。 此类错误通常表示代码中存在拼写错误或程序损坏。
虽然客户端代码可能会产生和传播这些错误,但实际上只有 V8 会这样做。
doesNotExist;
// 抛出 ReferenceError,doesNotExist 不是此程序中的变量。
除非应用程序动态生成和运行代码,否则 ReferenceError
实例表明代码或其依赖项中存在错误。
- Extends: <errors.Error>
Indicates that an attempt is being made to access a variable that is not defined. Such errors commonly indicate typos in code, or an otherwise broken program.
While client code may generate and propagate these errors, in practice, only V8 will do so.
doesNotExist;
// Throws ReferenceError, doesNotExist is not a variable in this program.
Unless an application is dynamically generating and running code,
ReferenceError
instances indicate a bug in the code or its dependencies.