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

Section "Assign this to component" example does no show it #43

Closed
etiennellipse opened this issue May 5, 2017 · 6 comments
Closed

Section "Assign this to component" example does no show it #43

etiennellipse opened this issue May 5, 2017 · 6 comments

Comments

@etiennellipse
Copy link

This section stipulates this:

assigning this to a variable named component the variable tells developers it's bound to the component instance wherever it's used.

The code example attached does not define any variable named component. It's confusing.

@Elfayer
Copy link
Contributor

Elfayer commented May 8, 2017

Right.

And I'd add a mention to explain that in ES6 you don't need anything like var self = this. But in ES5 you will.

@etiennellipse
Copy link
Author

Well, you don't need it when using arrow functions, since the lexical scope is kept. But you might if you are using a typical function for whatever reason.

@pablohpsilva
Copy link
Owner

pablohpsilva commented May 8, 2017

What do you think about this edit:

[...]
In other words: Do NOT code things like var self = this; anymore if you're using ES6. You're safe using Vue components.

Why

  • Using ES6, there's no need to save this to a variable;
  • In general, when using arrow functions the lexical scope is kept
  • If you're NOT using ES6 and, therefore, not using Arrow Functions, you'd have to add this to a variable. That's the only exception.

[...]

@Elfayer
Copy link
Contributor

Elfayer commented May 8, 2017

@pablohpsilva Sounds good to me!

Just some few points:

  • const is ES6, so I'd write var self = this;, on the first line.
  • Be consistent, write NOT in capital the "why" section.

@Elfayer
Copy link
Contributor

Elfayer commented May 30, 2017

[out of topic]
Congrats for the 1000 stars! ;)

@pablohpsilva
Copy link
Owner

Done guys! Thank you so much! :D

Thank you @Elfayer hehehehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants