Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

53 Delete data from an object

There are two ways to delete data from an object: delete the data and leave the keyword, or delete both the data and the keyword with the delete operator.

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

scale.name = "";
delete scale.pitches;

Which results in the following object:

{ 
	"name" : "" 
}