
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Explain the Error Name Values in JavaScript with examples.
The error name value is used for setting or returning the error name. The error name can return the below values.
Sl.No | Error Name & Description |
---|---|
1 | EvalError It represents an error in the eval() function |
2 | RangeError It happens when a numeric value is out of its range |
3 | ReferenceError It happens when an illegal reference has occured |
4 | SyntaxError It represents a syntax error |
5 | TypeError It represents a type error |
6 | URIError It represents an error in the encodeURI(). |
Example
Following is the code for the error name values in JavaScript −
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; } </style> </head> <body> <h1>Error name values in Javascript</h1> <div style="color: green;" class="result"></div> <button class="Btn">CLICK HERE</button> <h3> Click on the above button to call a variable before it is defined </h3> <script> let resEle = document.querySelector(".result"); document.querySelector(".Btn").addEventListener("click", () => { try { resEle.innerHTML = a; } catch (err) { resEle.innerHTML = "Error name = " + err.name; } let a = 44; }); </script> </body> </html>
Output
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
- Related Articles
- Explain the finally Statement in JavaScript with examples.
- Explain about EventHandler with Examples in JavaScript
- Explain JavaScript Error Object.
- JavaScript Error name Property
- What is JavaScript closure? Explain with examples.
- Explain JavaScript Regular Expression modifiers with examples
- Explain try and catch statements in JavaScript with examples.
- How to create constants in JavaScript? Explain with examples.
- Explain Stack in Python with examples
- Explain 5NF with examples in DBMS
- Explain Python Matrix with examples
- Explain 'Not a constructor function' error in JavaScript?
- Explain the concept of DBMS schema with examples?
- Explain Haploid" and "Diploid" with examples."
- Explain Chosen and Select2 with Examples

Advertisements