Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Edit the es6-const paragraph #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 90 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
5. [Classes](#classes)
6. [Testing](#testing)
7. [Concurrency](#concurrency)
8. [Formatting](#formatting)
9. [Comments](#comments)
8. [Error Handling](#error-handling)
9. [Formatting](#formatting)
10. [Comments](#comments)

## Introduction
![Humorous image of software quality estimation as a count of how many expletives
Expand Down Expand Up @@ -52,11 +53,10 @@ var yearMonthDay = moment().format('YYYY/MM/DD');
```
**[⬆ back to top](#table-of-contents)**

### Use ES6 constants when variable values do not change
In the bad example, the variable can be changed.
When you declare a constant, the variable should stay
the same throughout the program.

### Use ES6 constants when variable will not be reassigned
In the bad example, the variable can be reassigned.
When you declare a constant, the variable can only be altered.
If you want to reassign a variable use `let`.

**Bad:**
```javascript
Expand All @@ -66,6 +66,11 @@ var FIRST_US_PRESIDENT = "George Washington";
**Good**:
```javascript
const FIRST_US_PRESIDENT = "George Washington";

let CURRENT_US_PRESIDENT = "Donald Trump";
if (bool) {
CURRENT_US_PRESIDENT = "somone else";
}
```
**[⬆ back to top](#table-of-contents)**

Expand Down Expand Up @@ -379,7 +384,7 @@ function parseBetterJSAlternative(code) {
let ast = lexer(tokens);
ast.forEach((node) => {
// parse...
})
})
}
```
**[⬆ back to top](#table-of-contents)**
Expand Down Expand Up @@ -508,7 +513,7 @@ function createMenu(config) {
cancellable: true
}, config);

// config now equals: {title: "Order", body: "Bar", buttonText: "Send", cancellable: true}
// config now equals: {title: "Foo", body: "Bar", buttonText: "Baz", cancellable: true}
// ...
}

Expand Down Expand Up @@ -767,7 +772,7 @@ class Airplane {
return getMaxAltitude() - getPassengerCount();
case 'Air Force One':
return getMaxAltitude();
case 'Cesna':
case 'Cessna':
return getMaxAltitude() - getFuelExpenditure();
}
}
Expand All @@ -794,7 +799,7 @@ class AirForceOne extends Airplane {
}
}

class Cesna extends Airplane {
class Cessna extends Airplane {
//...
getCruisingAltitude() {
return getMaxAltitude() - getFuelExpenditure();
Expand Down Expand Up @@ -1318,7 +1323,7 @@ class DOMTraverser {

let $ = new DOMTraverser({
rootNode: document.getElementsByTagName('body'),
options: {
options: {
animationModule: function() {}
}
});
Expand Down Expand Up @@ -1793,6 +1798,79 @@ async function getCleanCodeArticle() {
**[⬆ back to top](#table-of-contents)**


## **Error Handling**
Thrown errors are a good thing! They mean the runtime has successfully
identified when something in your program has gone wrong and it's letting
you know by stopping function execution on the current stack, killing the
process (in Node), and notifying you in the console with a stack trace.

### Don't ignore caught errors
Doing nothing with a caught error doesn't give you the ability to ever fix
or react to said error. Logging the error to the console (`console.log`)
isn't much better as often times it can get lost in a sea of things printed
to the console. If you wrap any bit of code in a `try/catch` it means you
think an error may occur there and therefore you should have a plan,
or create a code path, for when it occurs.

**Bad:**
```javascript
try {
functionThatMightThrow();
} catch (error) {
console.log(error);
}
```

**Good:**
```javascript
try {
functionThatMightThrow();
} catch (error) {
// One option (more noisy than console.log):
console.error(error);
// Another option:
notifyUserOfError(error);
// Another option:
reportErrorToService(error);
// OR do all three!
}
```

### Don't ignore rejected promises
For the same reason you shouldn't ignore caught errors
from `try/catch`.

**Bad:**
```javascript
getdata()
.then(data => {
functionThatMightThrow(data);
})
.catch(error => {
console.log(error);
});
```

**Good:**
```javascript
getdata()
.then(data => {
functionThatMightThrow(data);
})
.catch(error => {
// One option (more noisy than console.log):
console.error(error);
// Another option:
notifyUserOfError(error);
// Another option:
reportErrorToService(error);
// OR do all three!
});
```

**[⬆ back to top](#table-of-contents)**


## **Formatting**
Formatting is subjective. Like many rules herein, there is no hard and fast
rule that you must follow. The main point is DO NOT ARGUE over formatting.
Expand Down