I’ve taken on a new project,and there’s a line of code that looks like this:
typeName() {
return {
1: 'leads',
2: 'cunstomer',
3: 'business'
}[this.optionValue]
},
it works well.
I’ve never seen before.
Then I tried in developer tools,but it don’t work!
Can anyone tell me why?
enter image description here
{1:'a'}[1]
Developer tools will report the error:Uncaught SyntaxError: Unexpected token ‘:’