blob: abf77777fc05b13b5797b3dc6d60c9978d4a7bb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
title: Error.prototype.name
slug: Web/JavaScript/Reference/Global_Objects/Error/name
tags:
- Error
- JavaScript
- Property
- Prototype
translation_of: Web/JavaScript/Reference/Global_Objects/Error/name
---
<div>{{JSRef}}</div>
<p>Die <code><strong>name</strong></code> Eigenschaft repräsentiert einen Namen für die Art des Errors. Der Initialwert ist "Error".</p>
<h2 id="Beschreibung">Beschreibung</h2>
<p>Als Standard wird für einer {{jsxref("Error")}} Instanz der Name "Error" gegeben. Die <code>name</code> Eigenschaft und die {{jsxref("Error.prototype.message", "message")}} Eigenschaft werden eingesetzt, um in der {{jsxref("Error.prototype.toString()")}} Methode eine Repräsentation des Fehlers als String zu erstellen.</p>
<h2 id="Beispiele">Beispiele</h2>
<h3 id="Einen_benutzerdefinierten_Fehler_erzeugen">Einen benutzerdefinierten Fehler erzeugen</h3>
<pre class="brush: js">var e = new Error('Malformed input'); // e.name ist 'Error'
e.name = 'ParseError';
throw e;
// e.toString() wird 'ParseError: Malformed input' zurückgeben.
</pre>
<h2 id="Spezifikationen">Spezifikationen</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Spezifikation</th>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-error.prototype.name', 'Error.prototype.name')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browserkompatibilität">Browserkompatibilität</h2>
<div>
<div>
<p>{{Compat("javascript.builtins.Error.name")}}</p>
</div>
</div>
<h2 id="Siehe_auch">Siehe auch</h2>
<ul>
<li>{{jsxref("Error.prototype.message")}}</li>
<li>{{jsxref("Error.prototype.toString()")}}</li>
</ul>
|