Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

68 Looping through Objects

Looping through the properties of an object is similar to that as with array, except with looping through the keys of the object instead of indexes:

function HandleMIDI(event) {
	var keys = Object.keys(event);
	var length = keys.length;
	for ( var thisKey = 0; thisKey < length; thisKey++ ) {
		var key = keys[thisKey];
		var value = event[key];
		Trace( key + ":" + value );
	}
}

In the above example: