The variables declared with "let" are limited to the scope of a block statement. Therefore, it is impossible to access to varaibles outside the constructor. In your code you are not accessing to the variables declared in the constructor function; you are creating other additional variables.
@thecollective24043 жыл бұрын
what to do to access those variables ?
@gautamjangir89273 жыл бұрын
Best Explanation Sir.....thanks.
@rambattena55554 жыл бұрын
Each and every point is clear...it's great to have ur subscribe sir...make more videos on javascript 🙏
@sdetpavan4 жыл бұрын
Sure I will
@Bunny_Love4 жыл бұрын
Thank you very much for such a wonderful explanation!
@sdetpavan2 жыл бұрын
Welcome
@satyasahoo264 жыл бұрын
Thank you so much. Good tutorial
@sdetpavan2 жыл бұрын
Welcome
@SameerKongath4 жыл бұрын
Nice explanation, thankyou sir
@sdetpavan2 жыл бұрын
You're most welcome
@freakkky22 күн бұрын
Sir, the variables inside of the constructor have never been used as you declare them using let. That makes a huge confusion. You should correct it.
@mohammedsuhailbasha48604 жыл бұрын
Very nice explaination sir thank you so much sir
@sdetpavan2 жыл бұрын
Welcome
@sajidsaiyed81692 жыл бұрын
But how is Encapsulation, I can direct access marks attributes with the student objects. so I can change marks directly without calling set methods. setMarks(marks){this.marks=marks} --> this.marks: belongs to objects so, I can directly set value into it. So it means you can access the property. Please correct me.
@sujathabaddipadige4424 жыл бұрын
Very good explanation sir thank you so much for uploading all the videos. After js which frontend framework is better now days like angular or reactjs
@rohitjadhav74222 жыл бұрын
superb
@sdetpavan2 жыл бұрын
thanks
@thecollective24043 жыл бұрын
marks and name variables are not being used as they are in the constructor.
@guruchandaguli2014 Жыл бұрын
That's why we are using 'this' keyword
@webtestingui71872 жыл бұрын
What is difference between this code and your code even i get same output without using the setmethods() class encapExample{ constructor(){ let name,age; } getName(){ return this.name; } setName(name){ this.name=name; } getAge(){ return this.age; } setAge(Age){ this.agage; } } let obj=new encapExample(); obj.name="Alex"; obj.age=20; console.log(obj.getName(),obj.getAge());