Merge branch 'main' into indonesian-translation

This commit is contained in:
hexatester
2020-11-21 06:41:59 +07:00
12 changed files with 346 additions and 36 deletions

View File

@@ -139,7 +139,7 @@ function displayDone() {
console.log('3 seconds has elapsed');
}
// timer value is in milliseconds
setTimeout(3000, displayDone);
setTimeout(displayDone, 3000);
```
### Anonymous functions
@@ -151,9 +151,9 @@ When we are passing a function as a parameter we can bypass creating one in adva
Let's rewrite the code above to use an anonymous function:
```javascript
setTimeout(3000, function() {
setTimeout(function() {
console.log('3 seconds has elapsed');
});
}, 3000);
```
If you run our new code you'll notice we get the same results. We've created a function, but didn't have to give it a name!
@@ -165,9 +165,9 @@ One shortcut common in a lot of programming languages (including JavaScript) is
Let's rewrite our code one more time to use a fat arrow function:
```javascript
setTimeout(3000, () => {
setTimeout(() => {
console.log('3 seconds has elapsed');
});
}, 3000);
```
### When to use each strategy

View File

@@ -28,9 +28,9 @@ Operators are used to evaluate conditions by making comparisons that will create
| Symbol | Description | Example |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `<` | **Greater than**: Compares two values and returns the `true` Boolean data type if the value on the right side is larger than the left | `5 < 6 // true` |
| `<=` | **Greater than or equal to**: Compares two values and returns the `true` Boolean data type if the value on the right side is larger than or equal to the left | `5 <= 6 // true` |
| `>` | **Less than**: Compares two values and returns the `true` Boolean data type if the value on the left side is larger than the right | `5 > 6 // false` |
| `<` | **Less than**: Compares two values and returns the `true` Boolean data type if the value on the left side is less than the right | `5 < 6 // true` |
| `<=` | **Less than or equal to**: Compares two values and returns the `true` Boolean data type if the value on the left side is less than or equal to the right | `5 <= 6 // true` |
| `>` | **Greater than**: Compares two values and returns the `true` Boolean data type if the value on the left side is larger than the right | `5 > 6 // false` |
| `>=` | **Less than or equal to**: Compares two values and returns the `true` Boolean data type if the value on the left side is larger than or equal to the right | `5 >= 6 // false` |
| `===` | **Strict equality**: Compares two values and returns the `true` Boolean data type if values on the right and left are equal AND are the same data type. | `5 === 6 // false` |
| `!==` | **Inequality**: Compares two values and returns the opposite Boolean value of what a strict equality operator would return | `5 !== 6 // true` |