Is there any possibility to create a constant for "this" in Lightning helper? I have tried the following syntaxis:

self : this,

initializeInputs : function(component, webLeadData) {}

But I receive the following error message:

Error:(1, 1) c.ddcm_quote: org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Invalid literal value [6, 12]: 'this'

  • you can use that in helper method not outside it. Jul 31, 2019 at 9:42
  • In each function of this helper I do the following: let self = this, and use this "self" where it is needed. I want to declare "self" one time outside of the function. Jul 31, 2019 at 9:43

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.