Skip to content
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

fixed example #388

Merged
merged 1 commit into from
Jan 19, 2017
Merged
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
14 changes: 7 additions & 7 deletions _posts/en/2017-01-19-binding-objects-to-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ A copy of the given function along with the specified `this` value and initial a
```js
const myCar = {
brand: 'Ford',
type: 'Sedan'
Color: ‘Red
type: 'Sedan',
color: 'Red'
};

const getBrand = () => {
const getBrand = function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the arrow function syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't bind arrow functions

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, sorry 👽

console.log(this.brand);
};

const getType = () => {
const getType = function() {
console.log(this.type);
};

const getColor = () => {
const getColor = function() {
console.log(this.color);
};

Expand All @@ -60,6 +60,6 @@ getBrand(myCar); // object not bind,undefined

getType.bind(myCar)(); // Sedan

getColor.bind(myCar); // Red
getColor.bind(myCar)(); // Red

```
```