add let before and see if that works.
for (let i = 0; i<components.length; i++){ console.log(i); if (components[i] != null){ components[i].draw(); } }