I am trying my best to aviod using variables with global scope but I am not sure the best way to achieve this, currently I have a function setSizes(), (this is run once on mousedown) which gets all the measurements and doStuff(), (this is run continually on mousemove) which uses all the sizes to perform various operations:
var sizes = {};
sizes.myWidth = 0;
sizes.myHeight = 0;
sizes.myPadding = 0;
sizes.myMargin = 0;
function setSizes(){
//sets all sizes
}
function doStuff(){
//does stuff with sizes
}
What is the best way to avoid this sort of code? I find myself doing it continually out of "simplicity" but I can't imagine it is the most efficient way.
var sizes = {};.