25-2.html

来自「我写的一些JS 请大家看看」· HTML 代码 · 共 35 行

HTML
35
字号
<html>
<head>
<title></title>
<script>
function throw_exception(message)
{
	var exception = new Error(message);
	throw exception;
}

function sinAB(a,b)
{

	try
	{
		if(typeof(a) != "number")
		throw_exception("第一个参数不是有效的数值!");
		if(typeof(b) != "number")
		throw_exception("第二个参数不是有效的数值!");
		var res = Math.sin(a)*Math.cos(b) + Math.cos(a) * Math.sin(b);
		return res;
	}
	catch(ex)
	{
		alert("调用sinAB()函数出现异常 => " + ex.message);		
	}
}
//调用sinAB()
var a = sinAB(3,'a');
</script>
</head>
<body>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?