minor fixes
This commit is contained in:
parent
613e921f73
commit
246156d6e2
4 changed files with 8 additions and 8 deletions
|
@ -194,7 +194,7 @@ First, the syntax: how to differentiate between them in the code.
|
|||
return a + b;
|
||||
}
|
||||
```
|
||||
- *Function Expression:* a function, created inside an expression or inside another syntax construct. Here, the function is created at the right side of the "assignment expression" `=`:
|
||||
- *Function Expression:* a function, created inside an expression or inside another syntax construct. Here, the function is created on the right side of the "assignment expression" `=`:
|
||||
|
||||
```js
|
||||
// Function Expression
|
||||
|
@ -291,7 +291,7 @@ if (age < 18) {
|
|||
welcome(); // \ (runs)
|
||||
*/!*
|
||||
// |
|
||||
function welcome() { // |
|
||||
function welcome() { // |
|
||||
alert("Hello!"); // | Function Declaration is available
|
||||
} // | everywhere in the block where it's declared
|
||||
// |
|
||||
|
@ -301,7 +301,7 @@ if (age < 18) {
|
|||
|
||||
} else {
|
||||
|
||||
function welcome() {
|
||||
function welcome() {
|
||||
alert("Greetings!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ We covered three ways to create a function in JavaScript:
|
|||
3. Arrow functions:
|
||||
|
||||
```js
|
||||
// expression at the right side
|
||||
// expression on the right side
|
||||
let sum = (a, b) => a + b;
|
||||
|
||||
// or multi-line syntax with { ... }, need return here:
|
||||
|
|
|
@ -206,7 +206,7 @@ delete user?.name; // delete user.name if user exists
|
|||
```
|
||||
|
||||
````warn header="We can use `?.` for safe reading and deleting, but not writing"
|
||||
The optional chaining `?.` has no use at the left side of an assignment.
|
||||
The optional chaining `?.` has no use on the left side of an assignment.
|
||||
|
||||
For example:
|
||||
```js run
|
||||
|
|
|
@ -81,7 +81,7 @@ That works, because internally a destructuring assignment works by iterating ove
|
|||
|
||||
|
||||
````smart header="Assign to anything at the left-side"
|
||||
We can use any "assignables" at the left side.
|
||||
We can use any "assignables" on the left side.
|
||||
|
||||
For instance, an object property:
|
||||
```js run
|
||||
|
@ -234,7 +234,7 @@ The basic syntax is:
|
|||
let {var1, var2} = {var1:…, var2:…}
|
||||
```
|
||||
|
||||
We should have an existing object at the right side, that we want to split into variables. The left side contains an object-like "pattern" for corresponding properties. In the simplest case, that's a list of variable names in `{...}`.
|
||||
We should have an existing object on the right side, that we want to split into variables. The left side contains an object-like "pattern" for corresponding properties. In the simplest case, that's a list of variable names in `{...}`.
|
||||
|
||||
For instance:
|
||||
|
||||
|
@ -420,7 +420,7 @@ alert( title ); // Menu
|
|||
|
||||
If an object or an array contain other nested objects and arrays, we can use more complex left-side patterns to extract deeper portions.
|
||||
|
||||
In the code below `options` has another object in the property `size` and an array in the property `items`. The pattern at the left side of the assignment has the same structure to extract values from them:
|
||||
In the code below `options` has another object in the property `size` and an array in the property `items`. The pattern on the left side of the assignment has the same structure to extract values from them:
|
||||
|
||||
```js run
|
||||
let options = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue