Can I simplify this conditional statement that uses the logical negation operator?

Sorry if this is a question such as "Logical operators 101". I look at my screen for 15 minutes, trying to wrap my head around me, but I'm stuck.

Is there a more concise / elegant way to express the following (this is JavaScript syntax, but this is not a language dependent question):

if (!something && !something_else) {
  // do something
}

Based on some experiments, this does not look like the logical equivalent:

if (!(something && something_else) {
  // do something
}

Also, can anyone recommend an online resource for further exploring such issues? I assume that this type of thing is covered by an abstract level in computer science curricula, and this is a significant gap in my programming knowledge that I really would like to fill. Thank!

+3
4
(Not A) And (Not B)

:

Not (A Or B)

+10

:

if (!(something || something else)) {
  // do something
}

.

+3

,

if (!(something || something_else)) {
  // do something
}

! something && &! something_else " -, -", " (-, -)"

+3

, , , , .

0

Source: https://habr.com/ru/post/1753104/


All Articles