Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
JS Global and Local
I was creating a game when I realised I had an issue. My function (called init) in which the variable ctx was stated couldn't be accessed by functions outside of it. So I decided to put the functions in init, but that didn't work. Now I don't know how to have things drawn in my code. I figured this has something to do with global and local scopes but I have little understanding of this. Could anyone help
1 Resposta
+ 2
You can probably instantiate your ctx variable on a globally scope which mean outside of any particular function, so all those functions can acess it as long as your code goes.
var ctx = value;
function init (){
// code
}