-
Notifications
You must be signed in to change notification settings - Fork 27
JSObject
Heather Arthur edited this page Jul 21, 2013
·
6 revisions
The class of the object. Functions have class "Function"
The name
of the function.
The displayName
of the function, if that property was set on the object.
ownPropertyNames(cb)
See Object.getOwnPropertyNames
obj.ownPropertyNames(function(err, names) {
console.log("first own property:", names[0]);
})
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(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(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);
})
})