I want to use "destructuring assignment" inside of a class function to get ride of using "this" keyword multiple time...
but i got this error:
Uncaught ReferenceError: a is not defined
my code is somthing like this:
class className {
constructor() {
this.a = 1;
this.b = 2;
this.c = 3;
}
function() {
[a, b, c] = [this.a, this.b, this.c];
}
}
let obj = new className;
obj.function();
(my purpose is to fill a 10*10 array with a
, b
and c
so I prefer to use a
instead of this.a
)