Interviewer And Interviewee Guide

Expert Developer JavaScript Interview Question:

How to manage exception handling in Javascript?

Submitted by: Administrator
► Javascript provides the features of exception handling using try..catch..finally blocks which is much similar to the C# exception handling blocks.
► We have to write the suspected code in try block and all the exceptions that occur in the try block will be caught in catch block.
► For example :
window.onload = function()
{
try
{
var v1=30;
var v2 =v1/v3;
}
catch(ex)
{
document.write(ex.name + " : " +ex.message);
}
Finally
{
document.write('this is finally block');
}
}
► This code snippet will cause an error :
TypeError : 'v3' is undefined.
Submitted by:

Read Online Expert Developer JavaScript Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.