Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

50 Get data from an object

There are multiple ways to get properties of an object.

var scale = {
		"name" : "C Major",
		"pitches" : [60, 62, 64, 65, 67, 69, 71]
	};
	
var name = scale.name;
var pitches = scale["pitches"];
var name2 = scale[0];

In the above example:

If a key is used which is not actually in the object, then the object will return undefined.