I try to use setter method with my class Test but my log return "TypeError: testObject.id is not a function"
class test {
constructor() {
this._id = 0;
}
get id(){
return this._id;
}
set id(newId){
this._id = newId;
}
}
const testObject = new test();
console.log(testObject.id); // return 0
testObject.id(12); //return TypeError: myTest.id is not a function
console.log(testObject.id);
I expect the ouput will be 12 but i obtain TypeError.