Can someone please assist with a strange issue I am experiencing in JavaScript?
After clicking on the 'test' link, an alert pops up displaying: "[]"
I was actually expecting to see something like: "[{'temp':25},{'thermState':'Notte'}]"
What could be causing this unexpected behavior?
<html>
<head>
<script type="text/javascript" charset="utf-8" src="js/json2.js"></script>
<script type="text/javascript" charset="utf-8">
function test(){
this.radioStates="";
this.state = [];
this.state["temp"]=25;
this.state["thermState"]="Notte";
alert(JSON.stringify(this.state));
}
</script>
</head>
<body>
<a href="#" onclick="test()">test</a>
</body>
</html>