Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

49 Create an Object

One way to declare an object is assigning the variable with a pair of empty braces { }, otherwise known as an object literal. This creates an object that is considered empty, meaning it has no key-value pairs:

var scale = {};

Another way to declare an object is assigning the variable with data between the braces:

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

In the above example:

The third way to declare an object is to use the new keyword otherwise known as an object constructor.

var scale = new Object();