Error

  1. Syntax 语法
new Error([message [, filename [, lineNumber]]])
  1. Error types 错误类型(8种)
  • Error
  • EvalError
  • InternalError
  • RangeError
  • ReferenceError
  • SyntaxError
  • TypeError
  • URIError
  1. Properties 属性
  • Error.propotype.name
  • Error.prototype.message
  1. demo
try{
  throw new Error('something is wrong')
}catch(error){
  console.log(e.name) // Error
  console.log(e.message) // something is wrong
}

try {
  foo.bar();
} catch (e) {
  console.log(e instanceof ReferenceError)  // true
  console.log(e.name)  // ReferenceError
}

你可能感兴趣的:(Error)