#Javascript #Tutorial #Hindi
Link for Complete JavaScript Tutorial in Hindi for Beginners: https://www.youtube.com/playlist?list=PLjpp5kBQLNTSvHo6Rp4Ky0X8x_MabmKye
Link for Complete HTML and CSS Tutorial in Hindi for Beginners: https://www.youtube.com/playlist?list=PLjpp5kBQLNTSdLVVjU_kea8J8lP24ZseT
In this video i will talk about JavaScript Accessors (Getters and Setters).
ECMAScript 5 (2009) introduced Getter and Setters.
Getters and setters allow you to define Object Accessors (Computed Properties).
Accessor properties are represented by “getter” and “setter” methods. In an object literal they are denoted by get and set
Sometimes it is desirable to allow access to a property that returns a dynamically computed value, or you may want to 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.
In JavaScript, a setter can be used to execute a function whenever a specified property is attempted to be changed. Setters are most often used in conjunction with getters to create a type of pseudo-property. It is not possible to simultaneously have a setter on a property that holds an actual value.
Why Using Getters and Setters?
1. It gives simpler syntax
2. It allows equal syntax for properties and methods
3. It can secure better data quality
4. It is useful for doing things behind-the-scenes
Please subscribe to watch more videos like this: https://www.youtube.com/channel/UCWCGvAu1NDCldmLasELk62g?sub_confirmation=1
Join this channel to support Tech Gun:
https://www.youtube.com/channel/UCWCGvAu1NDCldmLasELk62g/join