What does this operation in vuex mean, an array as a function name?

[types.CHANGE_LAYER_ZINDEX] (state, dir, index) {

...

}
as above, what is this operation in vuex, using an array object as the function name?

Mar.11,2021

you understand it wrong, you can refer to my code

const types = {ADD : 'add'}
class MyClass {

  constructor() {
    this.count = 0
  }

  [types.ADD] () {
       console.log(PPthis.count)
    }
}
let a = new Myclass()
a.add() //1
a[types.ADD] //2
The significance of

is that I have defined a constant that can dynamically call the method
. The advantage of this method is that it reduces the error rate and reduces the degree of freedom
to replace the freer way of writing
with higher readability and to improve readability. Define other references to this definition at once. More standardized
analogical java interface
for example, if you define PI = 3.14, you can directly refer to it. Then you need PI instead of using 3.14
every time. Just like the above only gives you actions that can be operated by this class, you can't add any more things

.

ps
I have stripped down the code above babel, refer to

var _createClass = function () { 
    function defineProperties(target, props) { 
        for (var i = 0; i < props.length; iPP) { 
            var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || 
            false;
            descriptor.configurable = true; 
            if ("value" in descriptor) 
            descriptor.writable = true; 
            Object.defineProperty(target, descriptor.key, descriptor); 
            } 
        } 
        return function (Constructor, protoProps, staticProps) { 
        if (protoProps) 
        defineProperties(Constructor.prototype, protoProps); 
        if (staticProps) 
            defineProperties(Constructor, staticProps); 
            return Constructor; 
            };
}();

function _classCallCheck(instance, Constructor)
    { 
        if (!(instance instanceof Constructor)) { 
        throw new TypeError("Cannot call a class as a function"); 
    } 
}

var types = { ADD: 'add' };

var MyClass = function () {
  function MyClass() {
    _classCallCheck(this, MyClass);

    this.count = 0;
  }

  _createClass(MyClass, [{
    key: types.ADD,
    value: function value() {
      console.log(PPthis.count);
    }
  }]);

  return MyClass;
}();

var a = new Myclass();
a.add(); //1
a[types.ADD]; //2

[types.CHANGE_LAYER_ZINDEX]

this is the evaluated attribute in es6. When executed, the expression is evaluated and replaced with the real value to call

.
New method and property name expression for object in

ES6.

let obj = {
  ['h' + 'ello']() {
    return 'hi';
  }
};

obj.hello()
The writing of the

constant is only a style, and as the official documentation says, it is not necessary to use it.

Menu