The reason you cannot do that is because that this
will directly point to window. This is not allowed in lightning because of locker service
.
Further Explanation:
helper
or controller
in lightning component are actually a part of closure function which would render like below in client machine:
(function () {
const { $A } = window;
return {
"meta": {
"name": "c$MyAuraComponent",
"extends": "markup://aura:component"
},
"controller": {
"doInit": function (component, event, helper) {
}
},
"helper": {
"helperMethod": function () {
},
"helperMethod2": function () {
}
}
};
}())
So here when you add variable pointing to this
in helper
, it will directly refer to window
. Hence it will not even compile.
Note: However, when you define this
inside helper function, its not a problem as function is scoped and lightning framework will take care of referring to helper functions.