0

I've read a lot about javascript getters/setters and I am trying to find a good reason for using them instead of just using two methods in their place! Could someone give me a small and intuitive example through which their power will emerge and make me understand the usefulness of them?

No matter how much I searched I did not find such an example...

Unknown developer
  • 5,414
  • 13
  • 52
  • 100
  • This looks interesting too: https://pragprog.com/articles/tell-dont-ask – Praveen Kumar Purushothaman Oct 23 '15 at 11:33
  • @Praveen KKumar, I believe the intent was to ask benefits of getters/setters for JS specifically. – Rajesh Oct 23 '15 at 11:37
  • 2
    @Rajesh That's a general topic, and I read it through, and found there's nothing specific we can say for JavaScript. All those things given there also suits it. Do you agree? – Praveen Kumar Purushothaman Oct 23 '15 at 11:37
  • I completely agree to it, But just thought user is looking for some real life examples in JS world for it like `watchers`. Initially even I had this question but then came across frameworks like AngularJS and Knockout and saw this concept in action. – Rajesh Oct 23 '15 at 11:40
  • @ILIAS, Kindly refer `$.watch` in *Angular JS* or `subscribe` method of *Knockout JS* for real life use of getters and setters – Rajesh Oct 23 '15 at 11:41

0 Answers0