From 4fed2cd57a8d461fdf2bba0d5a94b03bd6c94639 Mon Sep 17 00:00:00 2001 From: Dylan Bakr Date: Thu, 7 Oct 2021 13:38:17 -0400 Subject: [PATCH] [note] javascript operator precedence logical operator `if` will be executed before regular statements containing the console.log() and alert() methods --- .../02-reactivity/03-reactive-statements/text.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/site/content/tutorial/02-reactivity/03-reactive-statements/text.md b/site/content/tutorial/02-reactivity/03-reactive-statements/text.md index 1b0e90b7d5..a6a7e34561 100644 --- a/site/content/tutorial/02-reactivity/03-reactive-statements/text.md +++ b/site/content/tutorial/02-reactivity/03-reactive-statements/text.md @@ -24,4 +24,18 @@ $: if (count >= 10) { alert(`count is dangerously high!`); count = 9; } -``` \ No newline at end of file +``` + +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; +} +```