zoukankan      html  css  js  c++  java
  • javascript的抛异常简单介绍

    作用:和java类似,不过我觉得挺鸡肋的。哈哈,个人见解。。。

    上代码:123.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta charset="utf-8">
    <script type="text/javascript">
    function throwsNew(){
    	try{
    		throw new Error(10,"asdasdasd") ;
    	}catch(e){
    		alert(e.message); 
    		alert(e.description) 
    		alert(e.number) 
    		alert(e.name) 
    		throw new Error(10,"asdasdasd") 
    	}
    }
    
    function throwsDate(){
    	try {
    		 throw new Date(); // 抛出当前时间对象 
    	} catch (e) {
    		alert(e.message); 
    		alert(e.description) 
    		alert(e.number) 
    		alert(e.name) 
    		 alert(e.toLocaleString()); // 使用本地格式显示当前时间 
    	}
    }
    </script>
    </head>
    <body>		
    <a href="javascript:throwsNew()">抛异常</a>
    <a href="javascript:throwsDate()">抛异常</a>
    </body>
    </html>
    

      

  • 相关阅读:
    Alpha冲刺——第六天
    Alpha冲刺——第五天
    第一次课 圆面积
    计算器第四次作业
    计算器稍微小结
    附加作业3
    2016寒假训练4
    2016寒假训练3
    第三次作业
    2016寒假训练2
  • 原文地址:https://www.cnblogs.com/wang-s/p/4664037.html
Copyright © 2011-2022 走看看