I"m trying to teach my self coding for some mapping work, and I cannot seem to wrap my head around this.
I have a JavaScript function that is called from a button: This code connects my button using DOJO:
on(dom.byId("metro"), "change", updateLayerVisibility);
The following code correctly turns my layer off (metro is defined elsewhere)
function updateLayerVisibility(){
metro.setVisibility(false);
}
However if i try to use a variable I get an error that "test.setvisiblity is not a function"
function updateLayerVisibility(){
var test = "metro";
test.setVisibility(false);
}
So my question is what is the difference between these two? why isn't "metro" substituted for "test"? If its because the variable is a string, what should it be converted to.
Thanks (and sorry for the strange question)