Hey, is there any way you can make global variables in wick editor and/or js?
A variable declared outside a function, becomes GLOBAL .
A global variable has global scope : All scripts and functions on a web page can access it.
Example
var carName = "Volvo";
// code here can use carName
function myFunction() {
// code here can also use carName
}
yes, but… that will make the variable global for the current script tab, not for the entire wick project… if you want it globally for the entire wick application, you should use:
project.carName = "Volvo";
(the caveat is that you must call it in that way everywhere, since carName is not the same as project.carName)
You can also attach a variable to the window, like this:
window.carName= "Volvo";
Then you can refer to it as just carName
, or window.carName
from any script.
using variable like
window.carName should make more easy to modify them outside wick canvas
Imagine a button in your html page (outside wick) that change that value and having wick do something afterwards