WishMeLz

生活其实很有趣

错误异常try catch

try {
   
  // 可以通过手动抛出异常,通过e.message获取错误信息
    throw new Error("ERROR")
} catch (e) {
    console.log(e.message);
}

支持的错误异常

EvalError: raised when an error occurs executing code in eval()  
RangeError: raised when a numeric variable or parameter is outside of its valid range  
ReferenceError: raised when de-referencing an invalid reference  
SyntaxError: raised when a syntax error occurs while parsing code in eval()  
TypeError: raised when a variable or parameter is not a valid type  
URIError: raised when encodeURI() or decodeURI() are passed invalid parameters