-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Sometimes there is a requirement to use _this #493
Comments
Can you think of one? I can't. |
This (pardon the pun) maybe... App = {
init: function () {
// Init
this.cacheDom(); // OK
},
cacheDom: function () {
// Cache DOM
},
render: {
page1: function () {
// Need to re-cache DOM nodes
// this.cacheDom(); // Doesn't work as this is referencing render.
var _this = App.render;
_this.cacheDom(); // This works
},
page2: function () {
},
page3: function () {
}
}
} |
In that scenario, |
Fair point. I can't really think of a concrete scenario right now (checked my code and seems I don't use it apart from what I mentioned above.) Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the ES5 document it mentions using _this, but in ES6 it states () => {};. Surely there are occasions where _this is required? I use it sporadically of course, but I use it still.
The text was updated successfully, but these errors were encountered: