throwexample2.htm
来自「这是javascript高级程序设计的源码」· HTM 代码 · 共 24 行
HTM
24 行
<html>
<head>
<title>Try Catch Example</title>
<script type="text/javascript">
function addTwoNumbers(a, b) {
if (arguments.length < 2) {
throw new Error("Two numbers are required.");
} else {
return a + b;
}
}
try {
result = addTwoNumbers(90);
} catch (oException) {
alert(oException.message); //outputs "Two numbers are required."
}
</script>
</head>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?