0
What if I want to access all the properties of an object , how do I do that?
3 Answers
+ 8
class Test{
constructor(){
this.s1 = "Raj";
this.s2 = "hi";
this.s3 = "okay";
}
}
var t1 = new Test();
console.log(t1.s1);
console.log(t1.s2);
console.log(t1.s3);
+ 7
You can access only public properties by class' object.
If you want to access all properties, then make all of them public.
for example
#include <iostream>
using namespace std;
class Test{
public:
string a;
Test(){
a = "Raj";
}
};
int main() {
Test t1;
cout << t1.a;
return 0;
}
0
Could you please show me the Js way to do it, with couple more properties