Why I could not declare variable in setup and it still work and fine?
Where I could skip declaration, what is negative part of that skiping? - Main question
Here is example of code without declaration and it work fine:
function setup(){
canvas = createCanvas(innerWidth, innerHeight);
}
function mouseClicked(){
canvas.style('margin-top', '5px');
}
Here is same code with declaration how should it be:
let canvas;
function setup(){
canvas = createCanvas(innerWidth, innerHeight);
}
function mouseClicked(){
canvas.style('margin-top', '5px');
}
and I have also code in console that shows as it should be and I understand why it is so : declaration variables in console
It is working on any of DOM element (not only canvas)