I need to pass an object to another function but i have problems with global variables being referenced inside the object.
var a = 'first variable'; //SAMPLE GLOBAL VARIABLE
var b = 'second variable'; //SAMPLE GLOBAL VARIABLE
function iterator(options){
for(var c in options){
alert(c + ' ' + options[c]);
}
}
function main(){
iterator({
a:'5',
b:'6'
});
}
The functions should alert the output below
first variable 5
second variable 6
But instead I'm getting
a 5
b 6
I need to use variables inside the object.