try

The try JS Statements executes code that may throw an exception.

When the exception is caught, more code may be executed.

Syntax

try-catch

try
{
    code
}
catch(exception)
{
    code
}

try-finally

try
{
    code
}
finally
{
    code
}

try-catch-finally

try
{
    code
}
catch(exception)
{
    code
}
finally
{
    code
}

Examples

1 · try-catch

2 · try-finally

3 · try-catch-finally

HomeMenu