value.toString()を呼び出すために値をtoString()に戻す必要はありませんか? value.toString()を呼び出すことができるのはいつ知っていますか?それは書き込んだり、何かを返す前に.toString()を使用するのはいつ安全ですか?
<script>
var newList = function(val, lst)
{
return {
value: val,
tail: lst,
toString: function()
{
var result = this.value.toString();
if (this.tail != null)
result += "; " + this.tail.toString();
return result;
},
append: function(val)
{
if (this.tail == null)
this.tail = newList(val, null);
else
this.tail.append(val);
}
};
}
var list = newList("abc", null); // a string
list.append(3.14); // a floating-point number
list.append([1, 2, 3]); // an array
document.write(list.toString());
</script>
実際の質問には動詞と疑問符が付きます – Eric
「value.toString()を呼び出すには値をtoString()に戻す必要はありませんか?value.toString()を呼び出すことができることはいつ知っていますか? " –
この質問はリンクされたリストとは関係ありません。 –