Use one variable in create() and custom function

hello
i wanna to define one variable in create…
like below

create(){
const test = 0
}

and use that in custom function out of create()
like below

testFunc(){
    test++
}

update() {
this.testFunc()
}

how can i call test in another function?
thanks a lot

i know that i can define global variable in constructor
but in my case, thats not usefull

Use a class instance property instead of variable:

create(){
    this.test = 0
}

testFunc(){
    this.test++
}
1 Like