Handling Try Catch and Finally

Rajesh_Kumar
Posted by Rajesh_Kumar under JavaScript category on | Points: 40 | Views : 1294
function try_catch_finally
{
try
{
call_js_function();
alert('function exists')
}
catch(ex)
{
alert('An error has ocurred: '+ex.message);
}
finally
{
alert('finally block will be called always');
}
}


In above function i have called call_js_function().
But this function does not exist anywhere in the code or page.
When above function will be called then exception will be raised as

An error has ocurred: call_js_function is not defined

Then after finally block will be called and alert message will be shown as

finally block will be called always

So,this way we can handle try catch and finally in Javascript

Comments or Responses

Login to post response