Search code examples
javascriptpromisees6-promise

Calling .finally via bracket notation


Working with legacy code, I stumbled upon such code:

this.User.updateRole(params)
    .then(this._onUserDismissingSetSuccess(), this.$alert.error)
    ["finally"](function () {
        this.isSendingData = false;
    });

and some other occasions with ["finally"].

Which made me scratch my head: what's the deal, why not .finally()? Is it some pattern, some trick or what?


Solution

  • This must be really old code (or, code targeting really old browsers). Using keywords such as finally or catch with dot property access syntax was not supported in ES3. You had to quote these names in object literals and use bracket syntax when accessing these properties.