What would be the output of the following code snippet? | Promise Based Output Question | Part One
@Yomesh Gupta
This is the first question from a series of questions based on Promise functionality.
function init() {
throw new Error("I am an error");
return Promise.resolve(1);
}
init()
.then((v) => console.log(v + 1))
.catch((err) => console.log("Error caught -- ", err));
Option 1
2
Option 2
Error caught -- I am an error
Option 3
Uncaught Error: I am an error
Option 4
2 Error caught -- I am an error