I am using two classes in javascript.
class Challenge and class Modules, that extends Challenge.
in Challenge i have this constructor:
constructor() {
this.handles = [];
}
and this method:
bla() {
let elmnts = document.querySelectorAll("p"); // 5x
for(let i=0; i < elmnts.length; i++) {
let elmnt = elmnts[i];
this.handles[elmnt['id']] = elmnt; // saves the handles to each element in separate array for later use
}
}
in the child Class i am trying to use this “this.handles” array, but it is always empty.
It is not “undefined” but it is an empty array as i defined it in the constructor. its like the entries have never been set… but they are (as console.log() shows, when i insert it directly after the for()-loop)
console.log(this.handles); // --> []
Why does this happen?