Why does the global var debug get evaluated to [object Object] instead of to 1? Consider this code:
var debug = 1;
function hum(mess) {
alert('hum alert debug == ' + debug);
console.log('hum console.log debug == ' + debug);
if (debug == 1) {
console.error('hum mess == ' + mess);
} else {
console.error('hum debug != 1 mess == ' + mess);
}
}
When my code first runs the eval is made properly so my alert says ‘debug==1’ but later (perhaps after phonegap finishes loading) it starts giving me debug==[object Object]. I am developing using phonegap for ios using xcode and iphone simulator.
thanks
It looks like you’ve declared
debugas a global variable and it’s probably getting reassigned by other code loaded/executed later. Try changing the variable name or making it not global.