The below is another way of setting and getting property values and its really a very compatible mode.
Explanation:
1. Line no 6 we are creating value for name and age property. So the name and age will be assigned (setter).
2. In line no 8, we are getting age value.
Simple Example :
1 2 3 4 5 6 7 8 | function User(name, age) { this.name = name; this.age = age; } let john = new User("Test", 25); alert( john.age ); // 25 |
Explanation:
1. Line no 6 we are creating value for name and age property. So the name and age will be assigned (setter).
2. In line no 8, we are getting age value.
No comments:
Post a Comment