-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-handling.js
More file actions
29 lines (26 loc) · 939 Bytes
/
error-handling.js
File metadata and controls
29 lines (26 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Error handling in JavaScript is the process of dealing with errors that occur during the execution of a JavaScript program.
//Errors can be caused by a variety of factors, such as syntax errors, runtime errors, and logical errors.
// try {
// var a= "Helloo";
// console.log(a);
// dsfds;
// console.log("Hello World")
// } catch (error) {
// console.log("error ouccered");
// console.log(error.name); //error type
// console.log(error.message); //error real message
// console.log(error.stack); //overall message
// }
try {
//var a = "Hi; // syntex error missing "
//let json ={"Name:"avinash", "email":"test@email.com"} //unexpected error
console.log(json);
} catch (error) {
if(error instanceof ReferenceError){
console.log("Referance error");
}else if(error instanceof TypeError){
console.log("Type error");
}else{
console.log("unknow error");
}
}