Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Stored value

In the JSAPI, the stored value of an object property is its last known value. For a data property, this is exactly the same thing as the property's current value.

The JavaScript engine sets aside a field of type jsval for the stored value of most object properties, even properties that have getters. The stored value is updated each time the program gets or sets the property. The new stored value is the result of getting or setting the property, after the getter or setter, if any, is called.

JS_DefineProperty allows the application to specify a property's initial stored value.

JS_LookupProperty fetches a property's stored value without triggering its getter.

Properties with the JSPROP_SHARED attribute do not have a stored value. ES5 accessor properties, as in {get length() { return 0; }, automatically have JSPROP_SHARED.

Properties of objects that have custom JSObjectOps do not have a stored value.

Stored values are strong references for the purpose of garbage collection. As long as an object is reachable, the stored values of its properties are reachable and will not be collected.

Document Tags and Contributors

 Contributors to this page: fscholz, Jorend
 Last updated by: fscholz,