inspect(obj, [settings])

Inspects a given object or any other data item and prints the result to the console. This is useful for inspecting or debugging any kind of variable or data item. The optional settings object allows to control the function’s output. The following parameters can be set in the settings object:

  • showProps: Show or hide properties. Default: true
  • showValues: Show or hide values. Default: true
  • showMethods: Show or hide methods. Default: false
  • maxLevel: Chooses how many levels of properties should be inspected recursively. Default: 1
  • propList: Allows to pass an array of property names to show. If propList is not set all properties will be shown. Default: [] (no propList) If no settings object is set, the default values will be used.

Type: function

Parameter(s):

  • obj {Object}:

    An object or any other data item to be inspected.

  • settings {Object} Optional:

    A settings object to control the function’s behavior.

  • settings.showProps {Boolean} Optional:

    Show or hide properties. Default: true

  • settings.showValues {Boolean} Optional:

    Show or hide values. Default: true

  • settings.showMethods {Boolean} Optional:

    Show or hide methods. Default: false

  • settings.maxLevel {Number} Optional:

    How many levels of properties should be inspected recursively. Default: 1

  • settings.propList {Array} Optional:

    Array of properties to show. Default: [] (no propList)

Example(s):

Inspecting a string

inspect("foo");

Inspecting the current page, its methods and an additional level of properties

inspect(page(), {showMethods: true, maxLevel: 2})

Inspecting an ellipse, listing only the properties "geometricBounds" and "strokeWeight"

var myEllipse = ellipse(0, 0, 10, 10);
inspect(myEllipse, {maxLevel: 2, propList: ["geometricBounds, strokeWeight"]});