How to set the value defined in constructor outside in javascript

Viewed 25
function Service() {

    this.data = null;
    
}

Service.prototype.getData(){
return this.data;
}
Service.prototype.setData(x){
this.data=x;
}

I try to set the value and get it later but getData always gives null.

How to update the value and send it back

0 Answers
Related