js中的try/catch

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>robot</title>
    <script>
        window.onload = function(){
            try{
                var message = document.getElementById("message");
            } catch (error){
                console.log("Error:" + error.message);
            }
        }

    </script>
</head>
<body>

</body>
</html>
原文地址:https://www.cnblogs.com/themost/p/9366010.html