Getter and Setter Methods without Function Identifier Restriction
A JavaScript identifier must start with either a letter, underscore, or dollar sign:
|
|
But object property does have such a limitation:
|
|
And it works with accessor properties or getter and setter methods:
|
|
The syntax get '7/11'(){}
looks like function '7/11'(){}
, but it is not, getter and setter are still object properties. That is why it works. That’s another reason to use JavaScript object.