When I wrote
var c = { get a(){} };
The result is the c object has a "get a" and "set a" property.
Why?
Tested in Chrome and Firefox.
Sometimes it is desirable to allow access to a property that returns a dynamically computed value, or you may want reflect the status of an internal variable without requiring the use of explicit method calls. In JavaScript, this can be accomplished with the use of a getter. It is not possible to simultaneously have a getter bound to a property and have that property actually hold a value, although it is possible to use a getter and a setter in conjunction to create a type of pseudo-property.
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With