Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcfab4e commit d7b8cc1Copy full SHA for d7b8cc1
README.md
@@ -946,6 +946,35 @@ const bankAccount = new BankAccount();
946
947
// Buy shoes...
948
bankAccount.withdraw(100);
949
+```
950
+
951
+**Good with getter/setter**:
952
+```javascript
953
+class BankAccount {
954
+ constructor(balance = 1000) {
955
+ this_balance = balance;
956
+ }
957
958
+ // It doesn't have to be prefixed with `get` or `set` to be a getter/setter
959
+ set balance(amount) {
960
+ if (verifyAmountCanBeSetted(amount)) {
961
+ this._balance = amount;
962
963
964
965
+ get balance() {
966
+ return this._balance;
967
968
+}
969
970
+const bankAccount = new BankAccount();
971
972
+// Buy shoes...
973
+bankAccount.balance -= shoesPrice;
974
975
+// Get balance
976
+let balance = bankAccount.balance;
977
978
```
979
**[⬆ back to top](#table-of-contents)**
980
0 commit comments