标签:
1. Error 对象 EvalError RangeError TypeError ReferenceError
try{ notExists(); } catch(e){ alert(e.name+‘:‘+e.message); }
try{ var num =4 if(num!=0) throw new Error(‘why me?‘); }catch(e){ alert(‘in catch:‘+e.name+‘:‘+e.message); }finally{ alert(‘in finally‘); }
function myError(msg){ this.name = ‘God is ‘ this.message = msg||‘default self-defined error message‘; } myError.prototype = Object.create(Error.prototype); myError.prototype.constructor = myError; try { throw new myError(); } catch(e){ console.log(e.name +‘:‘+e.message); }
标签:
原文地址:http://www.cnblogs.com/goodearth/p/5170841.html