Array testing

by Christopher O

HTML

<div id="history">Begin<br /></div>

CSS

.inuse { background-color: #0f0;}

JavaScript

//var arr1 = ['a','b','c','d','e','f'];
//$('#history').append(JSON.stringify(arr1) + '<br />');

var flds = [
	{"n":"p1-1","x":413,"y":97,"w":243,"h":144,"g":"txt", "t":"Apple"},
  {"n":"p1-2","x":337,"y":23,"w":20,"h":20,"g":"initial"},
  {"n":"p1-3","x":301,"y":167,"w":20,"h":20,"g":"initial"},
  {"n":"p1-5","x":59,"y":325,"w":214,"h":77,"g":"txt"}
];

flds[1]["t"] = 'orange';
flds[1]["x"] = 100;


$('#history').append("0t: " + flds[0]["t"] + '<br />');

// ----------------------------------------------------------------------

var xx = {
	"a":{"x":413,"y":97,"w":243,"h":144,"g":"txt", "t":"Apple"},
  //"b":{"x":337,"y":23,"w":20,"h":20,"g":"initial", "t":"Ornage"},
 };
 
 xx["c"] = {"x":301,"y":167,"w":20,"h":20,"g":"initial", "t":"Blueberry"};
 
//$('#history').append(JSON.stringify(xx) + '<br />');
$('#history').append("ct: " + xx["c"]["t"] + '<br />');

if(xx["c3"] != undefined){
	$('#history').append('Key Exists<br />');

}

var count = 0;
for (k in xx) if (xx.hasOwnProperty(k)) count++;
$('#history').append('Count: '+count+'<br />');

$('#history').on( "click", function(e) {
	$(this).toggleClass('inuse', 500);
	$(this).append("<p>Click</p>");
});

//----------------------------------------------------------------------

var yy = {};

yy["c"] = 3;
yy["b"] = 2;
yy["a"] = 1;
$('#history').append('<br />yy: '+ yy["b"] +'<br />');
$('#history').append('<br />yy count: '+ Object.keys(yy).length +'<br />');