Skip to content
Heather Arthur edited this page Jul 21, 2013 · 6 revisions

Properties

class

The class of the object. Functions have class "Function"

name

The name of the function.

displayName

The displayName of the function, if that property was set on the object.

Methods

ownPropertyNames

ownPropertyNames(cb)

See Object.getOwnPropertyNames

obj.ownPropertyNames(function(err, names) {
  console.log("first own property:", names[0]);
})

ownPropertyDescriptor

ownPropertyDescriptor(name, cb)

See Object.getOwnPropertyDescriptor. Callback gets an object with properties: configurable (boolean), writable (boolean), enumerable (boolean), and value (a primitive or JSObject).

obj.ownPropertyDescriptor('foo', function(err, descriptor) {
  console.log("foo has value", descriptor.value);
})

ownProperties

ownProperties(cb)

Get all the properties of the object and not its prototype. Callback gets an object keyed on property name with property descriptor objects as values.

obj.ownProperties(function(err, properties) {
  for (name in properties) {
    console.log(name + ": " + properties[name].value);
  }
})

prototype

prototype(cb)

Get the prototype object of this object. See Object.prototype. Callback gets the prototype as a JSObject

obj.prototype(function(err, prototype) {
  prototype.ownPropertyNames(function(err, names) {
    console.log("prototype properties:", names);
  })
})
Clone this wiki locally