Skip to main content

own_property_including_array

Function own_property_including_array 

Source
pub fn own_property_including_array(
    object: &Gc<JsObject>,
    key: &PropertyKey,
) -> Option<Property>
Expand description

Walk the prototype chain from object looking for name.

Returns the object that owns the property along with the property itself. The owner matters for a store: an inherited accessor is invoked on the receiver, while an inherited data property is shadowed by a new own property. The own property key names on object, arrays included.

An array keeps its elements in an element vector and derives its length, so its property table knows about neither: a hole is a slot in the vector, not a missing property, and length is not stored at all. Array.prototype is itself an array, so every walk down the chain needs this same care — without it 1 in [1,,3] stayed false with Array.prototype[1] defined, "length" in [] was false outright, and a hole did not read an inherited element.