Property getters and setters thumbnail
Property getters and setters
javascript.info
But there is a widely known convention that properties starting with an underscore "_" are internal and should not be touched from outside the object. There are two kinds of object properties. From the outside, an accessor property looks like a regular one. Getters/setters can be used as wrappers ov
6 Users
0 Comments
105 Highlights
0 Notes

Top Highlights

  • But there is a widely known convention that properties starting with an underscore "_" are internal and should not be touched from outside the object.
  • There are two kinds of object properties.
  • From the outside, an accessor property looks like a regular one.
  • Getters/setters can be used as wrappers over “real” property values to gain more control over operations with them.
  • For instance, if we want to forbid too short names for user, we can have a setter name and keep the value in a separate property _name

Tags

Javascript

Ready to highlight and find good content?

Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.