DP_Debug:
Working with Custom Objects

Back to the Main Page

All of these examples assume that the library has been imported as noted in the Documentation.

While dump is useful with system object it really begins to shine when used to get the current state of your custom objects and information structures.

A Date

Assuming the following JavaScript object declaration:

	MyDate = new Date();

You can:

A String

Assuming the following JavaScript object declaration:

	MyString = new String("Hello World!");

You can:

A Simple Array

Assuming the following JavaScript array declaration:

	MyArray = [1,2,3,4,5];

You can:

A Simple Object

Assuming the following JavaScript object declaration:

	MyObject = {Prop1: "Value1", Prop2: "Value2"};

You can:

A Complex, Nested Object

Here we'll create a simple representation of a family: a married couple and two children. Note that the object contains recursive references: "John" and "Jill" reference each other as spouse.

Assuming the following JavaScript object declarations:

	Person1 =
	{	FirstName: "John",
		LastName: "Smith",
		Birthday: new Date(1970,04,23),
		Married: true
	}

	Person2 =
	{	FirstName: "Jill",
		LastName: "Smith",
		Birthday: new Date(1972,02,12),
		Married: true
	}

	Person3 =
	{	FirstName: "Timmy",
		LastName: "Smith",
		Birthday: new Date(2002,10,25),
		Married: false
	}

	Person4 =
	{	FirstName: "Susie",
		LastName: "Smith",
		Birthday: new Date(2000,01,04),
		Married: false
	}

	Person1.Spouse = Person2;
	Person2.Spouse = Person1;
	Person1.Children = [ Person3, Person4 ];
	Person2.Children = [ Person3, Person4 ];

	Family = [Person1, Person2, Person3, Person4];

You can: