What does it mean that some constants of js are enclosed in Chinese brackets?

what does js mean when some constants are enclosed in central brackets? For example, the following code:

export default {
  [RECEIVE_ADDRESS] (state, {address}) {
    state.address = address
  }

}


May.23,2021

let k = 'key';

let obj = {
    [k]:0
}

// => {key:0}

refer to http://es6.ruanyifeng.com/-sharpdo. may be Symbol


this code is redux-actions 's optimization of redux writing, which can be decomposed in this way

let type ="GET_DATA";
let actions = {};
actions[type]=(state,action)=>{return ...state,data:action.payload.data}

so it's actually

.
let obj = {
    name:"leinov"
}

get name

obj.name
//
obj["name"]

I feel that it is actually not as complicated as what those floors say. It may be the problem of removing the influence of quotation marks. In fact, there should be cont RECEIVE_ADDRESS = "receive_address" in the above, and then throw such an interface into the above file. You think, ah, if you directly use RECEIVE_ADDRESS as the function name, It becomes "receive_address" (state, {address}) {}, so it should be affordable and problematic for the string in quotation marks to be used as the function name, so add a square bracket to eliminate the problem (just a personal guess)

Menu