valueOf()
メソッドは、Boolean
オブジェクトのプリミティブ値を返します。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
構文
bool.valueOf()
戻り値
与えられた Boolean
オブジェクトのプリミティブ値です。
説明
valueOf
メソッドは、Boolean
オブジェクトのプリミティブ値か真偽値データ型としての Boolean
リテラルを返します。
このメソッドはたいてい JavaScript によって内部的に呼び出され、コードで明示的に呼び出されることはありません。
例
valueOf を使う
x = new Boolean(); myVar = x.valueOf() // myVar に false が代入される
仕様
使用 | ステータス | コメント |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | 標準 | 初期定義。JavaScript 1.1 で実装。 |
ECMAScript 5.1 (ECMA-262) Boolean.prototype.valueOf の定義 |
標準 | |
ECMAScript 2015 (6th Edition, ECMA-262) Boolean.prototype.valueOf の定義 |
標準 | |
ECMAScript (ECMA-262) Boolean.prototype.valueOf の定義 |
現行の標準 |
ブラウザー実装状況
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.