-1
I have a class to pass data
but when I call the class method this data
appears as null
. Why?
class Test {
constructor(data) {
this.myData = data;
}
MyFunction = () => {
return this.myData;
};
}
When I install this Class the console returns to me null
<script type="text/javascript">
var t = new Test({"data1", "data2", "data3"});
//
console.log( t.MyFunction() );
</script>
You probably want to
MyFunction (){
instead ofMyFunction = () => {
– Sergio