number.valueOf()メソッドは、Numberオブジェクトの数値を、プリミティブ値である数値型の数値として返すメソッド。
構文
number.valueOf()
戻り値
数値型の数値。
サンプル
<script type="text/javascript">
var $numberObject = new Number( 123 );
document.write( '$numberObject: ' );
document.write( $numberObject + '<br />' );
document.write( '$numberObjectのデータ型: ' );
document.write( typeof( $numberObject ) + '<br />' );
document.write( '$numberObject.valueOf(): ' );
document.write( $numberObject.valueOf() + '<br />' );
document.write( '$numberObject.valueOf()のデータ型: ' );
document.write( typeof( $numberObject.valueOf() ) + '<br />' );
</script>
var $numberObject = new Number( 123 );
document.write( '$numberObject: ' );
document.write( $numberObject + '<br />' );
document.write( '$numberObjectのデータ型: ' );
document.write( typeof( $numberObject ) + '<br />' );
document.write( '$numberObject.valueOf(): ' );
document.write( $numberObject.valueOf() + '<br />' );
document.write( '$numberObject.valueOf()のデータ型: ' );
document.write( typeof( $numberObject.valueOf() ) + '<br />' );
</script>
↓↓↓出力結果↓↓↓