EvalError
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
TheEvalError object indicates an error regarding the globaleval() function. This exception is not thrown by JavaScript anymore, however theEvalError object remains for compatibility.
EvalError is aserializable object, so it can be cloned withstructuredClone() or copied betweenWorkers usingpostMessage().
EvalError is a subclass ofError.
In this article
Constructor
EvalError()Creates a new
EvalErrorobject.
Instance properties
Also inherits instance properties from its parentError.
These properties are defined onEvalError.prototype and shared by allEvalError instances.
EvalError.prototype.constructorThe constructor function that created the instance object. For
EvalErrorinstances, the initial value is theEvalErrorconstructor.EvalError.prototype.nameRepresents the name for the type of error. For
EvalError.prototype.name, the initial value is"EvalError".
Instance methods
Inherits instance methods from its parentError.
Examples
>Creating an EvalError
try { throw new EvalError("Hello");} catch (e) { console.log(e instanceof EvalError); // true console.log(e.message); // "Hello" console.log(e.name); // "EvalError" console.log(e.stack); // Stack of the error}Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-native-error-types-used-in-this-standard-evalerror> |