JavaScriptのIF文で条件としてブール値を持つ変数を使用するにはどうすればよいですか?JavaScriptのIF文で条件としてブール値を持つ変数を使用するにはどうすればよいですか?
patt1 = new RegExp ("time");
var searchResult = (patt1.test("what time is it")); // search for the word time in the string
// and return true or false
If (searchResult = true) // what is the right syntax for the condition?
{
document.write("Word is in the statement");
document.write("<br />");
}
(、検索結果が) –
あなたが「条件」としてのみ変数を使用することができれば:=演算子は、JavaとJScriptで割り当てになるため動作しません= 1を使用して、 '(、検索結果)であれば、'、その構文を使用したい場合は 'if(searchResult == true)'を使うべきです – jere