Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
toString() は Boolean 値のメソッドで、指定された論理値を表す文字列を返します。
なし。
指定された論理値を表す文字列です。
Boolean オブジェクトは Object の toString メソッドを上書きしており、 Object.prototype.toString() を継承していません。Boolean 値の場合、toString メソッドは論理値の文字列表現を返します。この文字列は "true" または "false" のどちらかです。
この toString() メソッドは、その this 値が Boolean プリミティブまたはラッパーオブジェクトであることが要求されます。 this 値がそれ以外の場合、論理値への変換を試みることなく TypeError が発生します。
Boolean には [Symbol.toPrimitive]() メソッドがないため、 JavaScript は文字列を期待するコンテキストで Boolean オブジェクトが使用された場合(例:テンプレートリテラル など)、自動的に toString() メソッドを呼び出します。ただし、論理値のプリミティブは、文字列への変換を行う際に toString() メソッドを参照しません。代わりに、元の toString() 実装と同じアルゴリズムを使用して直接変換されます。
| ECMAScript® 2027 Language Specification # sec-boolean.prototype.tostring |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月30日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.