From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/function/tosource/index.html | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/function/tosource/index.html (limited to 'files/ja/web/javascript/reference/global_objects/function/tosource') diff --git a/files/ja/web/javascript/reference/global_objects/function/tosource/index.html b/files/ja/web/javascript/reference/global_objects/function/tosource/index.html new file mode 100644 index 0000000000..6fdc0141be --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/function/tosource/index.html @@ -0,0 +1,69 @@ +--- +title: Function.prototype.toSource() +slug: Web/JavaScript/Reference/Global_Objects/Function/toSource +tags: + - Function + - JavaScript + - Method + - Non-standard + - Obsolete +translation_of: Web/JavaScript/Reference/Global_Objects/Function/toSource +--- +
{{JSRef}} {{obsolete_header}}
+ +

toSource() メソッドは、オブジェクトのソースコードを表す文字列を返します。このメソッドは通常、コード中で明示的に呼び出されるのではなく、 JavaScript から内部的に呼び出されます。デバッグ中にオブジェクトの内容を調査する目的で toSource() を呼び出すことができます。

+ +

構文

+ +
function.toSource();
+
+ +

返値

+ +

オブジェクトのソースコードを表す文字列です。

+ +

解説

+ +

ネイティブ関数

+ +

組込みの {{jsxref("Function")}} オブジェクトでは、 toSource() は次の文字列を返してソースコードが使用できないことを示します。

+ +
function Function() {
+  [native code]
+}
+
+ +

独自の関数

+ +

独自に作成した関数では、 toSource() はオブジェクトを定義する JavaScript のソースコードを文字列として返します。

+ +
// 例:
+function hello() {
+  console.log("Hello, World!");
+}
+
+hello.toSource();
+
+ +
// 結果:
+"function hello() {
+    console.log(\"Hello, World!\");
+}"
+ +

仕様書

+ +

いずれの標準仕様でも定義されていません。

+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.Function.toSource")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf