javascript - getting message condition is always true -


i'm getting message resharper condition true following code

if (filters == "answers" || "solution") {  } 

what's happening here in code?

if (filters == "answers" || "solution") {  } 

in above code "solution" true

so, change

  if (filters == "answers" || filters =="solution") {      } 

example

if("i") {  } 

above true always.

so, in code second condition returns true

as per boolean or , [anything true] true

you have 2 predicates , truth table

   i/p               o/p true   false        true false  ture         true false  false         false true   true         true 

in code, never condition #1 , #3 so, true

so code true


Comments

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -