aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/function/tosource/index.html
blob: 75552bdc8c8e8594dbdc82622050b9ad8b2872fb (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: Function.prototype.toSource()
slug: Web/JavaScript/Reference/Global_Objects/Function/toSource
tags:
  - Function
  - JavaScript
  - Method
translation_of: Web/JavaScript/Reference/Global_Objects/Function/toSource
---
<div>{{JSRef}} {{non-standard_header}}</div>

<p>Die <code><strong>toSource()</strong></code> Methode gibt eine Stringrepräsentation des Quelltextes des Objektes zurück.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox"><var>function</var>.toSource();
Function.toSource();
</pre>

<h3 id="Rückgabewert">Rückgabewert</h3>

<p>Eine Stringrepräsentation des Quelltextes des Objektes.</p>

<h2 id="Beschreibung">Beschreibung</h2>

<p>Die <code>toSource</code> Methode gibt die folgenden Werte zurück:</p>

<ul>
 <li>Für das eingebaute {{jsxref("Function")}} Objekt gibt <code>toSource()</code> den folgenden String zurück, der angibt, dass der Quelltext nicht verfügbar ist:

  <pre class="brush: js">function Function() {
    [native code]
}
</pre>
 </li>
 <li>Für Benutzerdefinierte Funktionen, gibt <code>toSource()</code> den JavaScript Quelltext zurück, welcher das Objekt als String definiert.</li>
 <li>
  <pre class="brush: js">// Zum Beispiel:
function hello() {
  console.log("Hello, World!");
}

hello.toSource();</pre>
 </li>
 <li>
  <pre class="brush: js">// Das Resultat
"function hello() {
  console.log(\"Hello, World!\");
}"
</pre>
 </li>
</ul>

<p>Die Methode wird normalerweise von JavaScript selbst aufgerufen und nicht explizit im Quelltext. Man kann <code>toSource</code> während des Debuggens aufrufen, um zu ermitteln, was ein Objekt enthält.</p>

<h2 id="Spezifikationen">Spezifikationen</h2>

<p>Ist in keinem Standard. Implementiert in JavaScript 1.3.</p>

<h2 id="Browserkompatibilität">Browserkompatibilität</h2>

<div>


<p>{{Compat("javascript.builtins.Function.toSource")}}</p>
</div>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{jsxref("Object.prototype.toSource()")}}</li>
</ul>