Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Got this from java course - the same is valid for js " The idea behind encapsulation is to ensure that implementation details are not visible to users. The variables of one class will be hidden from the other classes, accessible only through the methods of the current class. This is called data hiding. To achieve encapsulation in Java, declare the class' variables as private and provide public setter and getter methods to modify and view the variables' values. "
20th Jan 2019, 4:29 PM
Seniru - avatar