minor fixes

This commit is contained in:
Ilya Kantor 2022-04-14 09:07:41 +03:00
parent 8831603275
commit 7959adf777

View file

@ -226,9 +226,9 @@ On the other hand, it's independently called every time when `text` is missing.
``` ```
````smart header="Default parameters in old JavaScript code" ````smart header="Default parameters in old JavaScript code"
Several years ago, JavaScript didn't support the syntax for default parameters. Several years ago, JavaScript didn't support the syntax for default parameters. So people used other ways to specify them.
So people used other ways to specify them. Nowadays, we can mostly come across them in old scripts. Nowadays, we can come across them in old scripts.
For example, an explicit check for `undefined`: For example, an explicit check for `undefined`:
@ -249,6 +249,7 @@ function showMessage(from, text) {
```js ```js
function showMessage(from, text) { function showMessage(from, text) {
// If the value of text is falsy, assign the default value // If the value of text is falsy, assign the default value
// this assumes that text == "" is the same as no text at all
text = text || 'no text given'; text = text || 'no text given';
... ...
} }