Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Scripting language Interviews:AngularJSAngularJS DeveloperChrome FrameDojoExpert Developer JavaScriptExpert JavaScript DeveloperExt CoreEXT-GWTExt-JSFront End Developer (AngularJS)JQuery DeveloperjQuery MobileJQuery ProgrammerJQuery UIMooToolsPrototype FrameworkQooxdooScriptingSencha TouchSizzle Selector EngineSWFObjectWeb Font LoaderXMLHttpRequest
Copyright © 2018. All Rights Reserved
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:
► 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:
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.