Development JavaScript Tutorial

< html>
    
        Try Catch Example
        
                function assert(bCondition, sErrorMessage) {
                    if (!bCondition) {
                        throw new Error(sErrorMessage);
                    }
                }
                try {
                    assert(1 == 2, "Two numbers are required.");
                } catch (oException) {
                    alert(oException.message);      //outputs "Two numbers are required."
                }