name
property represents a name for the type of error. The initial value is "Error".
默认情况下,
Error
instances are given the name "Error". The
name
property, in addition to the
message
property, is used by the
Error.prototype.toString()
method to create a string representation of the error.
var e = new Error('Malformed input'); // e.name is 'Error'
e.name = 'ParseError';
throw e;
// e.toString() would return 'ParseError: Malformed input'
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Error.prototype.name' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name
|
Chrome 1 | Edge 12 | Firefox 1 | IE 6 | Opera 4 | Safari 1 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
完整支持
Error
EvalError
InternalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()