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/boolean/tostring/index.html | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/boolean/tostring/index.html (limited to 'files/ja/web/javascript/reference/global_objects/boolean/tostring') diff --git a/files/ja/web/javascript/reference/global_objects/boolean/tostring/index.html b/files/ja/web/javascript/reference/global_objects/boolean/tostring/index.html new file mode 100644 index 0000000000..9d4961efd4 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/boolean/tostring/index.html @@ -0,0 +1,88 @@ +--- +title: Boolean.prototype.toString() +slug: Web/JavaScript/Reference/Global_Objects/Boolean/toString +tags: + - Boolean + - Boolean Methods + - JavaScript + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/toString +--- +
{{JSRef}}
+ +

toString() メソッドは、指定された Boolean オブジェクトを表す文字列を返します。

+ +
{{EmbedInteractiveExample("pages/js/boolean-tostring.html")}}
+ + + +

構文

+ +
bool.toString()
+ +

戻り値

+ +

指定された {{jsxref("Boolean")}} オブジェクトを表す文字列。

+ +

説明

+ +

{{jsxref("Boolean")}} オブジェクトは {{jsxref("Object")}} オブジェクトの toString メソッドを上書きしており、{{jsxref("Object.prototype.toString()")}} を継承していません。Boolean オブジェクトでは、toString メソッドはオブジェクトを文字列で表したものを返します。

+ +

{{jsxref("Boolean")}} が文字列値として表されるべきときや、{{jsxref("Boolean")}} が文字列の結合で参照されたとき、JavaScript は toString メソッドを自動的に呼び出します。

+ +

{{jsxref("Boolean")}} オブジェクトと真偽値では、組み込みの toString メソッドはその {{jsxref("Boolean")}} オブジェクトの値によって "true" か "false" の文字列を返します。

+ +

+ +

toString を使用する

+ +

以下のコードでは、flag.toString() は "true" を返します:

+ +
var flag = new Boolean(true);
+var myVar = flag.toString();
+ +

仕様

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
仕様ステータスコメント
{{SpecName('ES1')}}{{Spec2('ES1')}}初期定義。
{{SpecName('ES5.1', '#sec-15.6.4.2', 'Boolean.prototype.toString')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-boolean.prototype.tostring', 'Boolean.prototype.toString')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-boolean.prototype.tostring', 'Boolean.prototype.toString')}}{{Spec2('ESDraft')}} 
+ +

ブラウザー実装状況

+ +
+ + +

{{Compat("javascript.builtins.Boolean.toString")}}

+
+ +

関連項目

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