私の目的は特別のプロパティをカードに設定することです。私の最初の3つのconsole.logがfalse(デフォルト)を出力しますが、コードの後にはtrueを出力します。私はいくつかの方法を試しました(カードの方法を説明してthis.specialをtrueに設定し、後でメソッドを呼び出しました)。 カードを変更するだけです。特別なは機能しませんでした。ありがとう、オブジェクト値を上書きするプロトタイプ値を変更するにはどうすればよいですか?出来ますか?
function card(name,value,special) {
this.name = name,
this.value = value,
this.special = special
}
var a9 = new card("nine",9,false);
var a10 = new card("Ten",9,false);
var aal = new card("lower",9,false);
console.log(a9.special);
console.log(a10.special);
console.log(aal.special);
//code comes here
console.log(a9.special);
console.log(a10.special);
console.log(aal.special);
あなたはa9.special、a10.special、aa1.specialを個別に変更する必要があります。その点は個別に –
です。個別に使用する必要はありません。なぜなら私は30-60種類の異形を持つからです。 – Koppany
60個の変数... ugh ...なぜ 'card'の配列ではないのですか?次にカードを使うことができます。...(...) –