en.javascript.info/01-js/02-first-steps/13-logical-ops/07-if-question/solution.md
Ilya Kantor f301cb744d init
2014-10-26 22:10:13 +03:00

21 lines
643 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Ответ: первое и третье выполнятся.
Детали:
```js
//+ run
// Выполнится
// Результат -1 || 0 = -1, в логическом контексте true
if (-1 || 0) alert('первое');
// Не выполнится
// -1 && 0 = 0, в логическом контексте false
if (-1 && 0) alert('второе');
// Выполнится
// оператор && имеет больший приоритет, чем ||
// так что -1 && 1 выполнится раньше
// вычисления: null || -1 && 1 -> null || 1 -> 1
if (null || -1 && 1) alert('третье');
```