stringObject.toString()メソッドは、Stringオブジェクトの文字列を、文字列型の文字列として返すメソッド。
構文
stringObject.toString()
戻り値
文字列型の文字列。
サンプル
<script type="text/javascript">
var $numberObject = new String( '文字列' );
document.write( '$numberObject: ' );
document.write( $numberObject + '<br />' );
document.write( '$numberObjectのデータ型: ' );
document.write( typeof( $numberObject ) + '<br />' );
document.write( '$numberObject.toString(): ' );
document.write( $numberObject.toString() + '<br />' );
document.write( '$numberObject.toString()のデータ型: ' );
document.write( typeof( $numberObject.toString() ) + '<br />' );
</script>
var $numberObject = new String( '文字列' );
document.write( '$numberObject: ' );
document.write( $numberObject + '<br />' );
document.write( '$numberObjectのデータ型: ' );
document.write( typeof( $numberObject ) + '<br />' );
document.write( '$numberObject.toString(): ' );
document.write( $numberObject.toString() + '<br />' );
document.write( '$numberObject.toString()のデータ型: ' );
document.write( typeof( $numberObject.toString() ) + '<br />' );
</script>
↓↓↓出力結果↓↓↓