構文
toString()
パラメータ
なし
JavaScript 1.8.5 note
Starting in JavaScript 1.8.5, and consistent with ECMAScript 5th edition semantics, the toString() method is generic and can be used with any object. If the object has a join() method, it will be called and that value will be returned. Otherwise Object.prototype.toString() will be called, and the resulting value will be returned.
説明
Array オブジェクトは Object の toString メソッドを上書きしています。Array オブジェクトでは、toString メソッドは配列をつないで、配列のそれぞれの要素がコンマで区切られた 1 つの文字列を返します。例えば、以下のコードは配列を生成し、その配列を文字列に変換するために toString を使っています。
var monthNames = new Array("Jan","Feb","Mar","Apr");
myVar = monthNames.toString(); // myVar に "Jan,Feb,Mar,Apr" を代入
配列が文字列値として表されるべきときや、配列が文字列の結合で参照されたとき、JavaScript は toString メソッドを自動的に呼び出します。
Mozilla Developer Network