2017-10-29 7 views
-2

different results確認()の結果は

enter image description here

)(はconsole.logから異なる結果を返します。私は本当にどのように起こったのか混乱していた?プロンプトが表示されますが、なぜfalseを返すのと同じ文字の理由がありませんか?コンソールは同じタイプの真実を返しますか?

+0

もしあなたが驚いている理由を出力する二つの異なるもの、? –

+0

あなたは 'confirm'の代わりに' alert'を使用するでしょう – zevee

答えて

2

confirmの戻り値は、渡した式に基づいていません。これは、ユーザーがクリックしたボタンに基づいています。したがって、'y'==='n'は常にfalseですが、confirmは、OKボタンがクリックされた場合にtrueを返します。

console.log(confirm("If you click OK, 'true' is returned. If you click Cancel, 'false' is returned. What's returned has nothing to do with the value you pass to the confirm() method. That is simply the data to be displayed in the dialog."));

+0

お返事ありがとうございます。すべてが意味をなさない – theweebokid

+0

あまり心配しない私はちょうど5分後にそれを冷やす必要があります感謝再びスコット – theweebokid

関連する問題