[note] javascript operator precedence

logical operator  `if` will be executed before regular statements containing the console.log() and alert() methods
pull/6819/head
Dylan Bakr 5 years ago committed by GitHub
parent fffe8c16b7
commit 4fed2cd57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,4 +24,18 @@ $: if (count >= 10) {
alert(`count is dangerously high!`);
count = 9;
}
```
```
It is worth noting that you will never be alerted that `count` is 10. Regardless of the order of these two blocks, you will first be alerted that `count` is dangerously high before it is reset to 9. Only after this is it then logged to the console and used in the alert.
```js
$: {
console.log(`the count is ${count}`);
alert(`I SAID THE COUNT IS ${count}`);
}
```
```js
$: if (count >= 10) {
alert(`count is dangerously high!`);
count = 9;
}
```

Loading…
Cancel
Save