Boolean【真偽値】オブジェクト
メモ (概要外部リンク) コンストラクタ・型変換 プロパティ メソッド
メモ
概要
- 真偽値 (true / false)を表す オブジェクト
- Boolean型 【真偽型】も同等の処理が可能 (一時的に Boolean【真偽値】オブジェクト を作成)
- クラス定義による継承可能
外部リンク
- ECMA-262 (英語)
Boolean Objects ES2024 (15) ES2023 (14) ES2022 (13) Boolean.prototype.constructor ES2023 (14) ES2022 (13) ES2021 (12) Boolean.prototype ES2023 (14) ES2022 (13) ES2021 (12)
コンストラクタ・型変換
構文 | 説明 |
---|---|
new Boolean ( [ value ] ) | コンストラクタ |
Boolean ( [ value ] ) | 型変換 |
プロパティ
プロパティ | 説明 | |
---|---|---|
Boolean.prototype. | constructor | コンストラクタ定義 |
Boolean. | prototype | プロトタイプ |
console.log(Boolean.prototype);
// 出力:Boolean {[[PrimitiveValue]]: false, constructor: function, toString: function, valueOf: function}
var bool = true;
console.log(bool.constructor);
// 出力:function Boolean() { [native code] }
console.log(bool.toString());
// 出力:true
bool = new Boolean();
console.log(bool.toString());
// 出力:false
メソッド
メソッド | 説明 | |
---|---|---|
Boolean.prototype | toString () | 文字列変換 |
Boolean.prototype | valueOf () | Boolean型値変換 |