up
This commit is contained in:
parent
4ae129054e
commit
ab9ab64bd5
476 changed files with 3370 additions and 532 deletions
|
@ -0,0 +1,13 @@
|
|||
The answer: first `1`, then `2`.
|
||||
|
||||
```js run
|
||||
alert( alert(1) || 2 || alert(3) );
|
||||
```
|
||||
|
||||
The call to `alert` does not return a value. Or, in other words, it returns `undefined`.
|
||||
|
||||
1. The first OR `||` evaluates it's left operand `alert(1)`. That shows the first message with `1`.
|
||||
2. The `alert` returns `undefined`, so OR goes on to the second operand in it's search of a truthy value.
|
||||
3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert.
|
||||
|
||||
There will be no `3`, because the evaluation does not reach `alert(3)`.
|
12
1-js/02-first-steps/11-logical-operators/2-alert-or/task.md
Normal file
12
1-js/02-first-steps/11-logical-operators/2-alert-or/task.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
importance: 3
|
||||
|
||||
---
|
||||
|
||||
# What's the result of OR'ed alerts?
|
||||
|
||||
What the code below will output?
|
||||
|
||||
```js
|
||||
alert( alert(1) || 2 || alert(3) );
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue