In many OOP languages, to access a property of an object a get/set method is created.
Here's an example of what I mean in java
class MyClass{
private int prop;
public int getProp(){
return this.prop;
}
}
In JavaScript, is it better to access to object property in "OOP style" or just access directly?
class MyObj{
constructor(a){
this.a = a;
}
getA(){
return a;
}
}
o = new MyObj(1)
b = o.a //is this better?
b = o.getA() //or this?