欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

throw 抛出异常

程序员文章站 2022-05-05 08:54:21
...
<html>
	<head>
		<script>
			var x = prompt("Enter a number between 0 and 10:"," ");
			try{
				if(x>10 ) throw "err1";
				else if(x<0 )throw "err2";
					
			}catch(err){
				if(err=="err1") alert("Error! The value is too high");
				if(err=="err2") alert("Error! The value is too low");				
			}
		</script>
	</head>
	<body>		
	</body>	
</html>

相关标签: throw javascript