Skip to content

Correct mistake about OR short circuit #1897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 1-js/02-first-steps/11-logical-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl
In the example below, the first message is printed, while the second is not:

```js run no-beautify
*!*true*/!* || alert("printed");
*!*false*/!* || alert("not printed");
*!*false*/!* || alert("printed");
*!*true*/!* || alert("not printed");
```

In the first line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run.
In the second line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run.

Sometimes, people use this feature to execute commands only if the condition on the left part is truthy.
Sometimes, people use this feature to execute commands only if the condition on the left part is falsy.

## && (AND)

Expand Down