FrontendDeveloper.in

JavaScript question detail

What is the purpose of EvalError object

The EvalError object indicates an error regarding the global eval() function. Even though this exception is not thrown by JavaScript anymore, the EvalError object remains for compatibility. The syntax of this expression would be as below,

new EvalError([message[, fileName[, lineNumber]]])

You can throw EvalError with in try...catch block as below,

try {
throw new EvalError('Eval function error', 'someFile.js', 100);
} catch (e) {
console.log(e.message, e.name, e.fileName);              // "Eval function error", "EvalError", "someFile.js"
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399