JavaScript Displaying objects and XML interactively - console.dir(), console.dirxml()


Example

console.dir(object) displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.

var myObject = {
    "foo":{
        "bar":"data"
    }
};

console.dir(myObject);

displays:

enter image description here


console.dirxml(object) prints an XML representation of the descendant elements of object if possible, or the JavaScript representation if not. Calling console.dirxml() on HTML and XML elements is equivalent to calling console.log().

Example 1:

console.dirxml(document)

displays:

enter image description here

Example 2:

console.log(document)

displays:

enter image description here

Example 3:

var myObject = {
    "foo":{
        "bar":"data"
    }
};

console.dirxml(myObject);

displays:

enter image description here