+ 4
about getters and setters
What exactly do the getters and setters do in JavaScript? Can someone please answer me in brief .
4 Answers
+ 7
Hello, Shivam Mirje !
"Getter" - allows you to get values ââ(read values).
"Setter" - write values ââto a variable.
In the code they are the usual methods.
But the method name always starts with the prefix get or set.
+ 2
A good reference source-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
+ 2
Getters allow you to get the value, but you can add other code to it.
Setters allow you to set the value, and you can add other code to it.
Hope it helps!đ
+ 1
Thank you all for your answers. They helped me a lot. :)